1.1 --- a/test/unionfind_test.cc Tue Oct 30 10:51:07 2007 +0000
1.2 +++ b/test/unionfind_test.cc Tue Oct 30 20:21:10 2007 +0000
1.3 @@ -49,7 +49,7 @@
1.4 U.insert(1);
1.5 U.insert(2);
1.6
1.7 - check(U.join(1,2),"Test failed.");
1.8 + check(U.join(1,2) != -1,"Test failed.");
1.9
1.10 U.insert(3);
1.11 U.insert(4);
1.12 @@ -57,66 +57,58 @@
1.13 U.insert(6);
1.14 U.insert(7);
1.15
1.16 - check(U.join(1,4),"Test failed.");
1.17 - check(!U.join(2,4),"Test failed.");
1.18 - check(U.join(3,5),"Test failed.");
1.19
1.20 - U.insert(8,5);
1.21 + check(U.join(1,4) != -1,"Test failed.");
1.22 + check(U.join(2,4) == -1,"Test failed.");
1.23 + check(U.join(3,5) != -1,"Test failed.");
1.24
1.25 - check(U.size(4) == 3,"Test failed.");
1.26 - check(U.size(5) == 3,"Test failed.");
1.27 - check(U.size(6) == 1,"Test failed.");
1.28 - check(U.size(2) == 3,"Test failed.");
1.29 +
1.30 + U.insert(8,U.find(5));
1.31 +
1.32 +
1.33 + check(U.size(U.find(4)) == 3,"Test failed.");
1.34 + check(U.size(U.find(5)) == 3,"Test failed.");
1.35 + check(U.size(U.find(6)) == 1,"Test failed.");
1.36 + check(U.size(U.find(2)) == 3,"Test failed.");
1.37 +
1.38
1.39 U.insert(9);
1.40 - U.insert(10,9);
1.41 + U.insert(10,U.find(9));
1.42
1.43 - check(U.join(8,10),"Test failed.");
1.44
1.45 - check(U.move(9,4),"Test failed.");
1.46 - check(!U.move(9,2),"Test failed.");
1.47 + check(U.join(8,10) != -1,"Test failed.");
1.48
1.49 - check(U.size(4) == 4,"Test failed.");
1.50 - check(U.size(9) == 4,"Test failed.");
1.51
1.52 - check(U.move(5,6),"Test failed.");
1.53 + check(U.size(U.find(4)) == 3,"Test failed.");
1.54 + check(U.size(U.find(9)) == 5,"Test failed.");
1.55
1.56 - check(U.size(5) == 2,"Test failed.");
1.57 - check(U.size(8) == 3,"Test failed.");
1.58 -
1.59 - check(U.move(7,10),"Test failed.");
1.60 - check(U.size(7) == 4,"Test failed.");
1.61 + check(U.size(U.find(8)) == 5,"Test failed.");
1.62
1.63 U.erase(9);
1.64 U.erase(1);
1.65
1.66 - check(U.size(4) == 2,"Test failed.");
1.67 - check(U.size(2) == 2,"Test failed.");
1.68 + check(U.size(U.find(10)) == 4,"Test failed.");
1.69 + check(U.size(U.find(2)) == 2,"Test failed.");
1.70
1.71 U.erase(6);
1.72 - U.split(8);
1.73 + U.split(U.find(8));
1.74
1.75 - check(U.size(4) == 2,"Test failed.");
1.76 - check(U.size(3) == 1,"Test failed.");
1.77 - check(U.size(2) == 2,"Test failed.");
1.78
1.79 - check(U.join(3,4),"Test failed.");
1.80 - check(!U.join(2,4),"Test failed.");
1.81 + check(U.size(U.find(4)) == 2,"Test failed.");
1.82 + check(U.size(U.find(3)) == 1,"Test failed.");
1.83 + check(U.size(U.find(2)) == 2,"Test failed.");
1.84
1.85 - check(U.size(4) == 3,"Test failed.");
1.86 - check(U.size(3) == 3,"Test failed.");
1.87 - check(U.size(2) == 3,"Test failed.");
1.88
1.89 - U.makeRep(4);
1.90 - U.makeRep(3);
1.91 - U.makeRep(2);
1.92 + check(U.join(3,4) != -1,"Test failed.");
1.93 + check(U.join(2,4) == -1,"Test failed.");
1.94
1.95 - check(U.size(4) == 3,"Test failed.");
1.96 - check(U.size(3) == 3,"Test failed.");
1.97 - check(U.size(2) == 3,"Test failed.");
1.98
1.99 + check(U.size(U.find(4)) == 3,"Test failed.");
1.100 + check(U.size(U.find(3)) == 3,"Test failed.");
1.101 + check(U.size(U.find(2)) == 3,"Test failed.");
1.102
1.103 - U.eraseClass(4);
1.104 - U.eraseClass(7);
1.105 + U.eraseClass(U.find(4));
1.106 + U.eraseClass(U.find(7));
1.107
1.108 + return 0;
1.109 }