[Lemon-commits] [lemon_svn] alpar: r1048 - hugo/branches/hugo++/src/test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:57 CET 2006
Author: alpar
Date: Fri Aug 27 12:30:43 2004
New Revision: 1048
Modified:
hugo/branches/hugo++/src/test/unionfind_test.cc
Log:
- unionfind_test.cc uses the common check macro.
- Changed output messages.
Modified: hugo/branches/hugo++/src/test/unionfind_test.cc
==============================================================================
--- hugo/branches/hugo++/src/test/unionfind_test.cc (original)
+++ hugo/branches/hugo++/src/test/unionfind_test.cc Fri Aug 27 12:30:43 2004
@@ -2,19 +2,11 @@
#include <hugo/maps.h>
#include <hugo/unionfind.h>
+#include "test_tools.h"
using namespace hugo;
using namespace std;
-bool passed = true;
-
-void check(bool rc) {
- passed = passed && rc;
- if(!rc) {
- cout << "Test failed!" << endl;
- }
-}
-
template <typename T>
class BaseMap : public StdMap<int,T> {};
@@ -22,7 +14,7 @@
void print(UFE const &ufe) {
UFE::ClassIt cit;
- cout << "printing the classes of the structure:" << endl;
+ cout << "Print the classes of the structure:" << endl;
int i = 1;
for (ufe.first(cit); ufe.valid(cit); ufe.next(cit)) {
cout << " " << i << " (" << cit << "):" << flush;
@@ -43,19 +35,19 @@
print(U);
- cout << "Inserting 1..." << endl;
+ cout << "Insert 1..." << endl;
U.insert(1);
print(U);
- cout << "Inserting 2..." << endl;
+ cout << "Insert 2..." << endl;
U.insert(2);
print(U);
- cout << "Joining 1 and 2..." << endl;
- check(U.join(1,2));
+ cout << "Join 1 and 2..." << endl;
+ check(U.join(1,2),"Test failed.");
print(U);
- cout << "Inserting 3, 4, 5, 6, 7..." << endl;
+ cout << "Insert 3, 4, 5, 6, 7..." << endl;
U.insert(3);
U.insert(4);
U.insert(5);
@@ -63,129 +55,129 @@
U.insert(7);
print (U);
- cout << "Joining 1 - 4, 2 - 4 and 3 - 5 ..." << endl;
- check(U.join(1,4));
- check(!U.join(2,4));
- check(U.join(3,5));
+ cout << "Join 1 - 4, 2 - 4 and 3 - 5 ..." << endl;
+ check(U.join(1,4),"Test failed.");
+ check(!U.join(2,4),"Test failed.");
+ check(U.join(3,5),"Test failed.");
print(U);
- cout << "Inserting 8 to the component of 5 ..." << endl;
+ cout << "Insert 8 to the component of 5 ..." << endl;
U.insert(8,5);
print(U);
- cout << "size of the class of 4: " << U.size(4) << endl;
- check(U.size(4) == 3);
- cout << "size of the class of 5: " << U.size(5) << endl;
- check(U.size(5) == 3);
- cout << "size of the class of 6: " << U.size(6) << endl;
- check(U.size(6) == 1);
- cout << "size of the class of 2: " << U.size(2) << endl;
- check(U.size(2) == 3);
+ cout << "Size of the class of 4: " << U.size(4) << endl;
+ check(U.size(4) == 3,"Test failed.");
+ cout << "Size of the class of 5: " << U.size(5) << endl;
+ check(U.size(5) == 3,"Test failed.");
+ cout << "Size of the class of 6: " << U.size(6) << endl;
+ check(U.size(6) == 1,"Test failed.");
+ cout << "Size of the class of 2: " << U.size(2) << endl;
+ check(U.size(2) == 3,"Test failed.");
- cout << "Inserting 9 ..." << endl;
+ cout << "Insert 9 ..." << endl;
U.insert(9);
print(U);
- cout << "Inserting 10 to the component of 9 ..." << endl;
+ cout << "Insert 10 to the component of 9 ..." << endl;
U.insert(10,9);
print(U);
- cout << "Joining 8 and 10..." << endl;
- check(U.join(8,10));
+ cout << "Join 8 and 10..." << endl;
+ check(U.join(8,10),"Test failed.");
print(U);
cout << "Move 9 to the class of 4 ..." << endl;
- check(U.move(9,4));
+ check(U.move(9,4),"Test failed.");
print(U);
cout << "Move 9 to the class of 2 ..." << endl;
- check(!U.move(9,2));
+ check(!U.move(9,2),"Test failed.");
print(U);
- cout << "size of the class of 4: " << U.size(4) << endl;
- check(U.size(4) == 4);
- cout << "size of the class of 9: " << U.size(9) << endl;
- check(U.size(9) == 4);
+ cout << "Size of the class of 4: " << U.size(4) << endl;
+ check(U.size(4) == 4,"Test failed.");
+ cout << "Size of the class of 9: " << U.size(9) << endl;
+ check(U.size(9) == 4,"Test failed.");
cout << "Move 5 to the class of 6 ..." << endl;
- check(U.move(5,6));
+ check(U.move(5,6),"Test failed.");
print(U);
- cout << "size of the class of 5: " << U.size(5) << endl;
- check(U.size(5) == 2);
- cout << "size of the class of 8: " << U.size(8) << endl;
- check(U.size(8) == 3);
+ cout << "Size of the class of 5: " << U.size(5) << endl;
+ check(U.size(5) == 2,"Test failed.");
+ cout << "Size of the class of 8: " << U.size(8) << endl;
+ check(U.size(8) == 3,"Test failed.");
cout << "Move 7 to the class of 10 ..." << endl;
- check(U.move(7,10));
+ check(U.move(7,10),"Test failed.");
print(U);
- cout << "size of the class of 7: " << U.size(7) << endl;
- check(U.size(7) == 4);
+ cout << "Size of the class of 7: " << U.size(7) << endl;
+ check(U.size(7) == 4,"Test failed.");
- cout <<"erase 9: " << endl;
+ cout <<"Erase 9... " << endl;
U.erase(9);
print(U);
- cout <<"erase 1: " << endl;
+ cout <<"Erase 1... " << endl;
U.erase(1);
print(U);
- cout << "size of the class of 4: " << U.size(4) << endl;
- check(U.size(4) == 2);
- cout << "size of the class of 2: " << U.size(2) << endl;
- check(U.size(2) == 2);
+ cout << "Size of the class of 4: " << U.size(4) << endl;
+ check(U.size(4) == 2,"Test failed.");
+ cout << "Size of the class of 2: " << U.size(2) << endl;
+ check(U.size(2) == 2,"Test failed.");
- cout <<"erase 1: " << endl;
+ cout <<"Erase 1... " << endl;
U.erase(1);
print(U);
- cout <<"erase 6: " << endl;
+ cout <<"Erase 6... " << endl;
U.erase(6);
print(U);
- cout << "split the class of 8: " << endl;
+ cout << "Split the class of 8... " << endl;
U.split(8);
print(U);
- cout << "size of the class of 4: " << U.size(4) << endl;
- check(U.size(4) == 2);
- cout << "size of the class of 3: " << U.size(3) << endl;
- check(U.size(3) == 1);
- cout << "size of the class of 2: " << U.size(2) << endl;
- check(U.size(2) == 2);
+ cout << "Size of the class of 4: " << U.size(4) << endl;
+ check(U.size(4) == 2,"Test failed.");
+ cout << "Size of the class of 3: " << U.size(3) << endl;
+ check(U.size(3) == 1,"Test failed.");
+ cout << "Size of the class of 2: " << U.size(2) << endl;
+ check(U.size(2) == 2,"Test failed.");
- cout << "Joining 3 - 4 and 2 - 4 ..." << endl;
- check(U.join(3,4));
- check(!U.join(2,4));
+ cout << "Join 3 - 4 and 2 - 4 ..." << endl;
+ check(U.join(3,4),"Test failed.");
+ check(!U.join(2,4),"Test failed.");
print(U);
- cout << "size of the class of 4: " << U.size(4) << endl;
- check(U.size(4) == 3);
- cout << "size of the class of 3: " << U.size(3) << endl;
- check(U.size(3) == 3);
- cout << "size of the class of 2: " << U.size(2) << endl;
- check(U.size(2) == 3);
+ cout << "Size of the class of 4: " << U.size(4) << endl;
+ check(U.size(4) == 3,"Test failed.");
+ cout << "Size of the class of 3: " << U.size(3) << endl;
+ check(U.size(3) == 3,"Test failed.");
+ cout << "Size of the class of 2: " << U.size(2) << endl;
+ check(U.size(2) == 3,"Test failed.");
- cout << "makeRep(4)" << endl;
+ cout << "makeRep(4)..." << endl;
U.makeRep(4);
print(U);
- cout << "makeRep(3)" << endl;
+ cout << "makeRep(3)..." << endl;
U.makeRep(3);
print(U);
- cout << "makeRep(2)" << endl;
+ cout << "makeRep(2)..." << endl;
U.makeRep(2);
print(U);
- cout << "size of the class of 4: " << U.size(4) << endl;
- check(U.size(4) == 3);
- cout << "size of the class of 3: " << U.size(3) << endl;
- check(U.size(3) == 3);
- cout << "size of the class of 2: " << U.size(2) << endl;
- check(U.size(2) == 3);
+ cout << "Size of the class of 4: " << U.size(4) << endl;
+ check(U.size(4) == 3,"Test failed.");
+ cout << "Size of the class of 3: " << U.size(3) << endl;
+ check(U.size(3) == 3,"Test failed.");
+ cout << "Size of the class of 2: " << U.size(2) << endl;
+ check(U.size(2) == 3,"Test failed.");
cout << "eraseClass 4 ..." << endl;
@@ -197,9 +189,4 @@
print(U);
cout << "done" << endl;
-
- cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
- << endl;
-
- return passed ? 0 : 1;
}
More information about the Lemon-commits
mailing list