test/maps_test.cc
changeset 1203 8c567e298d7f
parent 1092 dceba191c00d
child 1210 da87dbdf3daf
equal deleted inserted replaced
31:bfafef51feb8 32:64bcd135383d
   728         check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true");
   728         check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true");
   729         ++n;
   729         ++n;
   730     }
   730     }
   731     check(n == 3, "Wrong number");
   731     check(n == 3, "Wrong number");
   732     check(map1.falseNum() == 3, "Wrong number");
   732     check(map1.falseNum() == 3, "Wrong number");
       
   733 
       
   734 #ifdef LEMON_CXX11
       
   735     {
       
   736       int c = 0;
       
   737       for(auto v: map1.items(false)) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   738       check(c == map1.falseNum(), "Wrong number");
       
   739     }
       
   740     {
       
   741       int c = 0;
       
   742       for(auto v: map1.items(true)) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   743       check(c == map1.trueNum(), "Wrong number");
       
   744     }
       
   745     {
       
   746       int c = 0;
       
   747       for(auto v: map1.falseKeys()) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   748       check(c == map1.falseNum(), "Wrong number");
       
   749     }
       
   750     {
       
   751       int c = 0;
       
   752       for(auto v: map1.trueKeys()) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   753       check(c == map1.trueNum(), "Wrong number");
       
   754     }
       
   755 #endif
       
   756 
   733   }
   757   }
   734 
   758 
   735   // Iterable int map
   759   // Iterable int map
   736   {
   760   {
   737     typedef SmartGraph Graph;
   761     typedef SmartGraph Graph;
   778     for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) {
   802     for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) {
   779       check(map1[static_cast<Item>(it)] == 1, "Wrong value");
   803       check(map1[static_cast<Item>(it)] == 1, "Wrong value");
   780       ++n;
   804       ++n;
   781     }
   805     }
   782     check(n == num, "Wrong number");
   806     check(n == num, "Wrong number");
       
   807 #ifdef LEMON_CXX11
       
   808     {
       
   809       int c = 0;
       
   810       for(auto v: map1.items(0)) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   811       check(c == (num + 1) / 2, "Wrong number");
       
   812       for(auto v: map1.items(1)) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   813       check(c == num, "Wrong number");
       
   814     }
       
   815 #endif
   783 
   816 
   784   }
   817   }
   785 
   818 
   786   // Iterable value map
   819   // Iterable value map
   787   {
   820   {
   836     for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) {
   869     for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) {
   837       check(map1[static_cast<Item>(it)] == 1.0, "Wrong value");
   870       check(map1[static_cast<Item>(it)] == 1.0, "Wrong value");
   838       ++n;
   871       ++n;
   839     }
   872     }
   840     check(n == num, "Wrong number");
   873     check(n == num, "Wrong number");
       
   874 
       
   875 #ifdef LEMON_CXX11
       
   876     {
       
   877       int c = 0;
       
   878       for(auto v: map1.items(0.0)) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   879       check(c == (num + 1) / 2, "Wrong number");
       
   880       for(auto v: map1.items(1.0)) { c++; ::lemon::ignore_unused_variable_warning(v); }
       
   881       check(c == num, "Wrong number");
       
   882     }
       
   883 #endif
   841 
   884 
   842   }
   885   }
   843 
   886 
   844   // Graph map utilities:
   887   // Graph map utilities:
   845   // mapMin(), mapMax(), mapMinValue(), mapMaxValue()
   888   // mapMin(), mapMax(), mapMinValue(), mapMaxValue()