# HG changeset patch # User klao # Date 1082574659 0 # Node ID be6fe0ea99b537c778cbbe7db864bf8d73ca1c37 # Parent 9ca84022df34cd0241c84543b2116a93792ab1e9 Test for the new style iter diff -r 9ca84022df34 -r be6fe0ea99b5 src/work/klao/iter_map_test.cc --- a/src/work/klao/iter_map_test.cc Wed Apr 21 18:56:26 2004 +0000 +++ b/src/work/klao/iter_map_test.cc Wed Apr 21 19:10:59 2004 +0000 @@ -26,6 +26,21 @@ } } +struct Int { + int a; + + Int(int b = 5) : a(b) {} + Int(Invalid) : a(-1) {} + + operator int() const { return a; } + + bool valid() { return a != -1; } +}; + +typedef StdMap BaseMap2; +typedef IterableBoolMap TestBoolMap2; + + int main() { { @@ -179,4 +194,36 @@ cout << " 42: " << test[42] << endl; } + + { + cout << "\n\n\nTest a masikfele iteralasra:\n"; + + BaseMap2 base(344); + TestBoolMap2 test(base,false); + + cout << "Inserting 12 to class true...\n"; + test.insert(12,true); + print(test,2); + + cout << "Inserting 22 to class true...\n"; + test.insert(22,true); + print(test,2); + + cout << "Inserting 10 to class false...\n"; + test.insert(10,false); + print(test,2); + + cout << "Testing some map values:\n"; + cout << " 12: " << test[12] << endl; + cout << " 22: " << test[22] << endl; + cout << " 10: " << test[10] << endl; + cout << " 42: " << test[42] << endl; + + cout << "The elements of the \"true\" class: "; + Int a; + for(test.first(a, true); a.valid(); test.next(a)) { + cout << " " << a; + } + cout << endl; + } }