Test for the new style iter
authorklao
Wed, 21 Apr 2004 19:10:59 +0000
changeset 366be6fe0ea99b5
parent 365 9ca84022df34
child 367 825647d4eca7
Test for the new style iter
src/work/klao/iter_map_test.cc
     1.1 --- a/src/work/klao/iter_map_test.cc	Wed Apr 21 18:56:26 2004 +0000
     1.2 +++ b/src/work/klao/iter_map_test.cc	Wed Apr 21 19:10:59 2004 +0000
     1.3 @@ -26,6 +26,21 @@
     1.4    }
     1.5  }
     1.6  
     1.7 +struct Int {
     1.8 +  int a;
     1.9 +
    1.10 +  Int(int b = 5) : a(b) {}
    1.11 +  Int(Invalid) : a(-1) {}
    1.12 +
    1.13 +  operator int() const { return a; }
    1.14 +
    1.15 +  bool valid() { return a != -1; }
    1.16 +};
    1.17 +
    1.18 +typedef StdMap<Int,int> BaseMap2;
    1.19 +typedef IterableBoolMap<BaseMap2> TestBoolMap2;
    1.20 +
    1.21 +
    1.22  int main() {
    1.23  
    1.24    {
    1.25 @@ -179,4 +194,36 @@
    1.26      cout << " 42: " << test[42] << endl;
    1.27  
    1.28    }
    1.29 +
    1.30 +  {
    1.31 +    cout << "\n\n\nTest a masikfele iteralasra:\n";
    1.32 +
    1.33 +    BaseMap2 base(344);
    1.34 +    TestBoolMap2 test(base,false);
    1.35 +
    1.36 +    cout << "Inserting 12 to class true...\n";
    1.37 +    test.insert(12,true);
    1.38 +    print(test,2);
    1.39 +
    1.40 +    cout << "Inserting 22 to class true...\n";
    1.41 +    test.insert(22,true);
    1.42 +    print(test,2);
    1.43 +
    1.44 +    cout << "Inserting 10 to class false...\n";
    1.45 +    test.insert(10,false);
    1.46 +    print(test,2);
    1.47 +
    1.48 +    cout << "Testing some map values:\n";
    1.49 +    cout << " 12: " << test[12] << endl;
    1.50 +    cout << " 22: " << test[22] << endl;
    1.51 +    cout << " 10: " << test[10] << endl;
    1.52 +    cout << " 42: " << test[42] << endl;
    1.53 +
    1.54 +    cout << "The elements of the \"true\" class: ";
    1.55 +    Int a;
    1.56 +    for(test.first(a, true); a.valid(); test.next(a)) {
    1.57 +      cout << " " << a;
    1.58 +    }
    1.59 +    cout << endl;
    1.60 +  }
    1.61  }