Changeset 1569:2a455f46f85a in lemon0.x
 Timestamp:
 07/19/05 14:40:23 (15 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2068
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/unionfind_test.cc
r1435 r1569 50 50 UFE U(base); 51 51 52 // print(U); 52 U.insert(1); 53 U.insert(2); 53 54 54 cout << "Insert 1..." << endl;55 U.insert(1);56 // print(U);57 58 cout << "Insert 2..." << endl;59 U.insert(2);60 // print(U);61 62 cout << "Join 1 and 2..." << endl;63 55 check(U.join(1,2),"Test failed."); 64 // print(U);65 56 66 cout << "Insert 3, 4, 5, 6, 7..." << endl;67 57 U.insert(3); 68 58 U.insert(4); … … 70 60 U.insert(6); 71 61 U.insert(7); 72 // print (U);73 62 74 cout << "Join 1  4, 2  4 and 3  5 ..." << endl;75 63 check(U.join(1,4),"Test failed."); 76 64 check(!U.join(2,4),"Test failed."); 77 65 check(U.join(3,5),"Test failed."); 78 // print(U);79 66 80 cout << "Insert 8 to the component of 5 ..." << endl;81 67 U.insert(8,5); 82 // print(U);83 68 84 cout << "Size of the class of 4: " << U.size(4) << endl;85 69 check(U.size(4) == 3,"Test failed."); 86 cout << "Size of the class of 5: " << U.size(5) << endl;87 70 check(U.size(5) == 3,"Test failed."); 88 cout << "Size of the class of 6: " << U.size(6) << endl;89 71 check(U.size(6) == 1,"Test failed."); 90 cout << "Size of the class of 2: " << U.size(2) << endl;91 72 check(U.size(2) == 3,"Test failed."); 92 73 93 cout << "Insert 9 ..." << endl;94 74 U.insert(9); 95 // print(U);96 cout << "Insert 10 to the component of 9 ..." << endl;97 75 U.insert(10,9); 98 // print(U);76 check(U.join(8,10),"Test failed."); 99 77 100 cout << "Join 8 and 10..." << endl; 101 check(U.join(8,10),"Test failed."); 102 // print(U); 78 check(U.move(9,4),"Test failed."); 79 check(!U.move(9,2),"Test failed."); 103 80 104 cout << "Move 9 to the class of 4 ..." << endl; 105 check(U.move(9,4),"Test failed."); 106 // print(U); 81 check(U.size(4) == 4,"Test failed."); 82 check(U.size(9) == 4,"Test failed."); 107 83 108 cout << "Move 9 to the class of 2 ..." << endl; 109 check(!U.move(9,2),"Test failed."); 110 // print(U); 84 check(U.move(5,6),"Test failed."); 111 85 112 cout << "Size of the class of 4: " << U.size(4) << endl;113 check(U.size(4) == 4,"Test failed.");114 cout << "Size of the class of 9: " << U.size(9) << endl;115 check(U.size(9) == 4,"Test failed.");116 117 cout << "Move 5 to the class of 6 ..." << endl;118 check(U.move(5,6),"Test failed.");119 // print(U);120 121 cout << "Size of the class of 5: " << U.size(5) << endl;122 86 check(U.size(5) == 2,"Test failed."); 123 cout << "Size of the class of 8: " << U.size(8) << endl;124 87 check(U.size(8) == 3,"Test failed."); 125 88 126 cout << "Move 7 to the class of 10 ..." << endl;127 89 check(U.move(7,10),"Test failed."); 128 // print(U);129 130 cout << "Size of the class of 7: " << U.size(7) << endl;131 90 check(U.size(7) == 4,"Test failed."); 132 91 133 cout <<"Erase 9... " << endl;134 92 U.erase(9); 135 // print(U);93 U.erase(1); 136 94 137 cout <<"Erase 1... " << endl;138 U.erase(1);139 // print(U);140 141 cout << "Size of the class of 4: " << U.size(4) << endl;142 95 check(U.size(4) == 2,"Test failed."); 143 cout << "Size of the class of 2: " << U.size(2) << endl;144 96 check(U.size(2) == 2,"Test failed."); 145 97 98 U.erase(1); 99 U.erase(6); 100 U.split(8); 146 101 147 cout <<"Erase 1... " << endl;148 U.erase(1);149 // print(U);150 151 cout <<"Erase 6... " << endl;152 U.erase(6);153 // print(U);154 155 cout << "Split the class of 8... " << endl;156 U.split(8);157 // print(U);158 159 160 cout << "Size of the class of 4: " << U.size(4) << endl;161 102 check(U.size(4) == 2,"Test failed."); 162 cout << "Size of the class of 3: " << U.size(3) << endl;163 103 check(U.size(3) == 1,"Test failed."); 164 cout << "Size of the class of 2: " << U.size(2) << endl;165 104 check(U.size(2) == 2,"Test failed."); 166 105 167 168 cout << "Join 3  4 and 2  4 ..." << endl;169 106 check(U.join(3,4),"Test failed."); 170 107 check(!U.join(2,4),"Test failed."); 171 // print(U);172 108 173 174 cout << "Size of the class of 4: " << U.size(4) << endl;175 109 check(U.size(4) == 3,"Test failed."); 176 cout << "Size of the class of 3: " << U.size(3) << endl;177 110 check(U.size(3) == 3,"Test failed."); 178 cout << "Size of the class of 2: " << U.size(2) << endl;179 111 check(U.size(2) == 3,"Test failed."); 180 112 181 cout << "Calling makeRep(4)..." << endl;182 113 U.makeRep(4); 183 // print(U);184 cout << "Calling makeRep(3)..." << endl;185 114 U.makeRep(3); 186 // print(U);187 cout << "Calling makeRep(2)..." << endl;188 115 U.makeRep(2); 189 // print(U);190 116 191 cout << "Size of the class of 4: " << U.size(4) << endl;192 117 check(U.size(4) == 3,"Test failed."); 193 cout << "Size of the class of 3: " << U.size(3) << endl;194 118 check(U.size(3) == 3,"Test failed."); 195 cout << "Size of the class of 2: " << U.size(2) << endl;196 119 check(U.size(2) == 3,"Test failed."); 197 120 198 121 199 cout << "eraseClass 4 ..." << endl;200 122 U.eraseClass(4); 201 // print(U);123 U.eraseClass(7); 202 124 203 cout << "eraseClass 7 ..." << endl;204 U.eraseClass(7);205 // print(U);206 207 cout << "done." << endl;208 125 }
Note: See TracChangeset
for help on using the changeset viewer.