Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/dataStructures/basic/unit/testSetPair.cpp
Go to the documentation of this file.
00001 
00009 #include "SetPair.h"
00010 #include "Utest.h"
00011 
00012 using namespace grafalgo;
00013 
00014 void basicTests() {
00015         int n = 10; SetPair sp(n); string s;
00016 
00017         cout << "writing initial pair " << sp.toString(s) << endl;
00018 
00019         Utest::assertTrue(!sp.isIn(1) && sp.firstIn() == 0 && sp.lastIn() == 0,
00020                           "initial inSet non-empty");
00021         Utest::assertTrue(sp.isOut(1) && sp.firstOut() != 0 && sp.lastOut() !=0,
00022                           "initial outSet does not contain all elements");
00023 
00024         sp.swap(1);
00025         Utest::assertEqual(sp.toString(s),"{a} {b c d e f g h i j}",
00026                            "set pair does not match expected value");
00027         sp.swap(4);
00028         Utest::assertEqual(sp.toString(s),"{a d} {b c e f g h i j}",
00029                            "set pair does not match expected value");
00030         sp.swap(10);
00031         Utest::assertEqual(sp.toString(s),"{a d j} {b c e f g h i}",
00032                            "set pair does not match expected value");
00033         sp.swap(2); sp.swap(5); sp.swap(9);
00034         Utest::assertEqual(sp.toString(s),"{a d j b e i} {c f g h}",
00035                            "set pair does not match expected value");
00036         cout << "writing balanced pair " << sp.toString(s) << endl;
00037 
00038         sp.swap(4); sp.swap(5); sp.swap(1); sp.swap(9);
00039         Utest::assertEqual(sp.toString(s),"{j b} {c f g h d e a i}",
00040                            "set pair does not match expected value");
00041 
00042         cout << "writing final pair " << sp.toString(s) << endl;
00043 }
00044 
00048 int main() {
00049         cout << "running basic tests\n";
00050         basicTests();
00051         cout << "basic tests passed\n";
00052 
00053         // add more systematic tests for each individual method
00054 }
 All Classes Files Functions Variables Typedefs Friends