ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

unordered_test.cpp
Go to the documentation of this file.
00001 #include <vector>
00002 #include <algorithm>
00003 #include <string>
00004 #if defined (STLPORT)
00005 #  include <unordered_map>
00006 #  include <unordered_set>
00007 #endif
00008 
00009 //#include <iostream>
00010 
00011 #include "cppunit/cppunit_proxy.h"
00012 
00013 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
00014 using namespace std;
00015 #  if defined (STLPORT)
00016 using namespace std::tr1;
00017 #  endif
00018 #endif
00019 
00020 //
00021 // TestCase class
00022 //
00023 class UnorderedTest : public CPPUNIT_NS::TestCase
00024 {
00025   CPPUNIT_TEST_SUITE(UnorderedTest);
00026 #if !defined (STLPORT) 
00027   CPPUNIT_IGNORE;
00028 #endif
00029   CPPUNIT_TEST(uset);
00030   CPPUNIT_TEST(umultiset);
00031   CPPUNIT_TEST(umap);
00032   CPPUNIT_TEST(umultimap);
00033   CPPUNIT_TEST(user_case);
00034   CPPUNIT_TEST(hash_policy);
00035   CPPUNIT_TEST(buckets);
00036   CPPUNIT_TEST(equal_range);
00037   CPPUNIT_EXPLICIT_TEST(benchmark1);
00038   CPPUNIT_EXPLICIT_TEST(benchmark2);
00039 #if !defined (_STLP_USE_CONTAINERS_EXTENSION)
00040   CPPUNIT_IGNORE;
00041 #endif
00042   CPPUNIT_TEST(template_methods);
00043   CPPUNIT_TEST_SUITE_END();
00044 
00045 protected:
00046   void uset();
00047   void umultiset();
00048   void umap();
00049   void umultimap();
00050   void user_case();
00051   void hash_policy();
00052   void buckets();
00053   void equal_range();
00054   void benchmark1();
00055   void benchmark2();
00056   void template_methods();
00057 };
00058 
00059 CPPUNIT_TEST_SUITE_REGISTRATION(UnorderedTest);
00060 
00061 const int NB_ELEMS = 2000;
00062 
00063 //
00064 // tests implementation
00065 //
00066 void UnorderedTest::uset()
00067 {
00068 #if defined (STLPORT)
00069   typedef unordered_set<int, hash<int>, equal_to<int> > usettype;
00070   usettype us;
00071 
00072   //Small compilation check of the copy constructor:
00073   usettype us2(us);
00074   //And assignment operator
00075   us = us2;
00076 
00077   int i;
00078   pair<usettype::iterator, bool> ret;
00079   for (i = 0; i < NB_ELEMS; ++i) {
00080     ret = us.insert(i);
00081     CPPUNIT_ASSERT( ret.second );
00082     CPPUNIT_ASSERT( *ret.first == i );
00083 
00084     ret = us.insert(i);
00085     CPPUNIT_ASSERT( !ret.second );
00086     CPPUNIT_ASSERT( *ret.first == i );
00087   }
00088 
00089   vector<int> us_val;
00090 
00091   usettype::local_iterator lit, litEnd;
00092   for (i = 0; i < NB_ELEMS; ++i) {
00093     lit = us.begin(us.bucket(i));
00094     litEnd = us.end(us.bucket(i));
00095 
00096     usettype::size_type bucket_pos = us.bucket(*lit);
00097     for (; lit != litEnd; ++lit) {
00098       CPPUNIT_ASSERT( us.bucket(*lit) == bucket_pos );
00099       us_val.push_back(*lit);
00100     }
00101   }
00102 
00103   //A compilation time check to uncomment from time to time
00104   {
00105     //usettype::iterator it;
00106     //CPPUNIT_ASSERT( it != lit );
00107   }
00108 
00109   sort(us_val.begin(), us_val.end());
00110   for (i = 0; i < NB_ELEMS; ++i) {
00111     CPPUNIT_ASSERT( us_val[i] == i );
00112   }
00113 #endif
00114 }
00115 
00116 void UnorderedTest::umultiset()
00117 {
00118 #if defined (STLPORT)
00119   typedef unordered_multiset<int, hash<int>, equal_to<int> > usettype;
00120   usettype us;
00121 
00122   int i;
00123   usettype::iterator ret;
00124   for (i = 0; i < NB_ELEMS; ++i) {
00125     ret = us.insert(i);
00126     CPPUNIT_ASSERT( *ret == i );
00127 
00128     ret = us.insert(i);
00129     CPPUNIT_ASSERT( *ret == i );
00130   }
00131 
00132   CPPUNIT_ASSERT( us.size() == 2 * NB_ELEMS );
00133   vector<int> us_val;
00134 
00135   usettype::local_iterator lit, litEnd;
00136   for (i = 0; i < NB_ELEMS; ++i) {
00137     lit = us.begin(us.bucket(i));
00138     litEnd = us.end(us.bucket(i));
00139 
00140     usettype::size_type bucket_pos = us.bucket(*lit);
00141     for (; lit != litEnd; ++lit) {
00142       CPPUNIT_ASSERT( us.bucket(*lit) == bucket_pos );
00143       us_val.push_back(*lit);
00144     }
00145   }
00146 
00147   sort(us_val.begin(), us_val.end());
00148   for (i = 0; i < NB_ELEMS; ++i) {
00149     CPPUNIT_ASSERT( us_val[2 * i] == i );
00150     CPPUNIT_ASSERT( us_val[2 * i + 1] == i );
00151   }
00152 #endif
00153 }
00154 
00155 void UnorderedTest::umap()
00156 {
00157 #if defined (STLPORT)
00158   typedef unordered_map<int, int, hash<int>, equal_to<int> > umaptype;
00159   umaptype us;
00160 
00161   //Compilation check of the [] operator:
00162   umaptype us2;
00163   us[0] = us2[0];
00164   us.clear();
00165 
00166   {
00167     //An other compilation check
00168     typedef unordered_map<int, umaptype> uumaptype;
00169     uumaptype uus;
00170     umaptype const& uref = uus[0];
00171     umaptype ucopy = uus[0];
00172     ucopy = uref;
00173     //Avoids warning:
00174     //(void*)&uref;
00175   }
00176 
00177   int i;
00178   pair<umaptype::iterator, bool> ret;
00179   for (i = 0; i < NB_ELEMS; ++i) {
00180     umaptype::value_type p1(i, i);
00181     ret = us.insert(p1);
00182     CPPUNIT_ASSERT( ret.second );
00183     CPPUNIT_ASSERT( *ret.first == p1 );
00184 
00185     umaptype::value_type p2(i, i + 1);
00186     ret = us.insert(p2);
00187     CPPUNIT_ASSERT( !ret.second );
00188     CPPUNIT_ASSERT( *ret.first == p1 );
00189   }
00190 
00191   {
00192     //Lets look for some values to see if everything is normal:
00193     umaptype::iterator umit;
00194     for (int j = 0; j < NB_ELEMS; j += NB_ELEMS / 100) {
00195       umit = us.find(j);
00196 
00197       CPPUNIT_ASSERT( umit != us.end() );
00198       CPPUNIT_ASSERT( (*umit).second == j );
00199     }
00200   }
00201 
00202   CPPUNIT_ASSERT( us.size() == (size_t)NB_ELEMS );
00203   vector<pair<int, int> > us_val;
00204 
00205   umaptype::local_iterator lit, litEnd;
00206   for (i = 0; i < NB_ELEMS; ++i) {
00207     lit = us.begin(us.bucket(i));
00208     litEnd = us.end(us.bucket(i));
00209 
00210     umaptype::size_type bucket_pos = us.bucket((*lit).first);
00211     for (; lit != litEnd; ++lit) {
00212       CPPUNIT_ASSERT( us.bucket((*lit).first) == bucket_pos );
00213       us_val.push_back(make_pair((*lit).first, (*lit).second));
00214     }
00215   }
00216 
00217   sort(us_val.begin(), us_val.end());
00218   for (i = 0; i < NB_ELEMS; ++i) {
00219     CPPUNIT_ASSERT( us_val[i] == make_pair(i, i) );
00220   }
00221 #endif
00222 }
00223 
00224 void UnorderedTest::umultimap()
00225 {
00226 #if defined (STLPORT)
00227   typedef unordered_multimap<int, int, hash<int>, equal_to<int> > umaptype;
00228   umaptype us;
00229 
00230   int i;
00231   umaptype::iterator ret;
00232   for (i = 0; i < NB_ELEMS; ++i) {
00233     umaptype::value_type p(i, i);
00234     ret = us.insert(p);
00235     CPPUNIT_ASSERT( *ret == p );
00236 
00237     ret = us.insert(p);
00238     CPPUNIT_ASSERT( *ret == p );
00239   }
00240 
00241   CPPUNIT_ASSERT( us.size() == 2 * NB_ELEMS );
00242   typedef pair<int, int> ptype;
00243   vector<ptype> us_val;
00244 
00245   umaptype::local_iterator lit, litEnd;
00246   for (i = 0; i < NB_ELEMS; ++i) {
00247     lit = us.begin(us.bucket(i));
00248     litEnd = us.end(us.bucket(i));
00249 
00250     umaptype::size_type bucket_pos = us.bucket((*lit).first);
00251     for (; lit != litEnd; ++lit) {
00252       CPPUNIT_ASSERT( us.bucket((*lit).first) == bucket_pos );
00253       us_val.push_back(ptype((*lit).first, (*lit).second));
00254     }
00255   }
00256 
00257   sort(us_val.begin(), us_val.end());
00258   for (i = 0; i < NB_ELEMS; ++i) {
00259     ptype p(i, i);
00260     CPPUNIT_ASSERT( us_val[i * 2] == p );
00261     CPPUNIT_ASSERT( us_val[i * 2 + 1] == p );
00262   }
00263 #endif
00264 }
00265 
00266 void UnorderedTest::user_case()
00267 {
00268 #if defined (STLPORT)
00269   typedef unordered_map<int, string> UnorderedMap1;
00270   typedef unordered_map<int, UnorderedMap1> UnorderedMap2;
00271 
00272   UnorderedMap1 foo;
00273   UnorderedMap2 bar;
00274 
00275   foo.insert(UnorderedMap1::value_type(1, string("test1")));
00276   foo.insert(UnorderedMap1::value_type(2, string("test2")));
00277   foo.insert(UnorderedMap1::value_type(3, string("test3")));
00278   foo.insert(UnorderedMap1::value_type(4, string("test4")));
00279   foo.insert(UnorderedMap1::value_type(5, string("test5")));
00280 
00281   bar.insert(UnorderedMap2::value_type(0, foo));
00282   UnorderedMap2::iterator it = bar.find(0);
00283   CPPUNIT_ASSERT( it != bar.end() );
00284 
00285   UnorderedMap1 &body = it->second;
00286   UnorderedMap1::iterator cur = body.find(3);
00287   CPPUNIT_ASSERT( cur != body.end() );
00288 
00289   body.erase(body.begin(), body.end());
00290   CPPUNIT_ASSERT( body.empty() );
00291 #endif
00292 }
00293 
00294 void UnorderedTest::hash_policy()
00295 {
00296 #if defined (STLPORT)
00297   unordered_set<int> int_uset;
00298 
00299   CPPUNIT_ASSERT( int_uset.max_load_factor() == 1.0f );
00300   CPPUNIT_ASSERT( int_uset.load_factor() == 0.0f );
00301 
00302   size_t nbInserts = int_uset.bucket_count() - 1;
00303   for (int i = 0; (size_t)i < nbInserts; ++i) {
00304     int_uset.insert(i);
00305   }
00306   CPPUNIT_ASSERT( int_uset.size() == nbInserts );
00307 
00308   int_uset.max_load_factor(0.5f);
00309   int_uset.rehash(0);
00310   CPPUNIT_ASSERT( int_uset.load_factor() < int_uset.max_load_factor() );
00311 
00312   size_t bucketsHint = int_uset.bucket_count() + 1;
00313   int_uset.rehash(bucketsHint);
00314   CPPUNIT_ASSERT( int_uset.bucket_count() >= bucketsHint );
00315 
00316   CPPUNIT_ASSERT( int_uset.key_eq()(10, 10) );
00317   CPPUNIT_ASSERT( int_uset.hash_function()(10) == 10 );
00318 #endif
00319 }
00320 
00321 void UnorderedTest::buckets()
00322 {
00323 #if defined (STLPORT) 
00324   unordered_set<int> int_uset;
00325 
00326   CPPUNIT_ASSERT( int_uset.bucket_count() < int_uset.max_bucket_count() );
00327 
00328   int i;
00329   size_t nbBuckets = int_uset.bucket_count();
00330   size_t nbInserts = int_uset.bucket_count() - 1;
00331   for (i = 0; (size_t)i < nbInserts; ++i) {
00332     int_uset.insert(i);
00333   }
00334   CPPUNIT_ASSERT( nbBuckets == int_uset.bucket_count() );
00335 
00336   size_t bucketSizes = 0;
00337   for (i = 0; (size_t)i < nbBuckets; ++i) {
00338     bucketSizes += int_uset.bucket_size(i);
00339   }
00340   CPPUNIT_ASSERT( bucketSizes == int_uset.size() );
00341 #endif
00342 }
00343 
00344 void UnorderedTest::equal_range()
00345 {
00346 #if defined (STLPORT)
00347   typedef unordered_multiset<size_t> umset;
00348   {
00349     //General test
00350     umset iumset;
00351     iumset.max_load_factor(10.0f);
00352 
00353     size_t nbBuckets = iumset.bucket_count();
00354 
00355     for (size_t i = 0; i < nbBuckets; ++i) {
00356       iumset.insert(i);
00357       iumset.insert(i + nbBuckets);
00358       iumset.insert(i + 2 * nbBuckets);
00359       iumset.insert(i + 3 * nbBuckets);
00360       iumset.insert(i + 4 * nbBuckets);
00361     }
00362 
00363     CPPUNIT_ASSERT( nbBuckets == iumset.bucket_count() );
00364     CPPUNIT_ASSERT( iumset.size() == 5 * nbBuckets );
00365 
00366     pair<umset::iterator, umset::iterator> p = iumset.equal_range(1);
00367     CPPUNIT_ASSERT( p.first != p.second );
00368 
00369     size_t nbElems = iumset.size();
00370     nbElems -= distance(p.first, p.second);
00371     for (umset::iterator j = p.first; j != p.second;) {
00372       iumset.erase(j++);
00373     }
00374 
00375     CPPUNIT_ASSERT( nbElems == iumset.size() );
00376 
00377     p = iumset.equal_range(2);
00378     CPPUNIT_ASSERT( p.first != p.second );
00379     nbElems -= distance(p.first, p.second);
00380     iumset.erase(p.first, p.second);
00381     CPPUNIT_ASSERT( nbElems == iumset.size() );
00382   }
00383 
00384   {
00385     //More specific test that tries to put many values in the same bucket
00386     umset iumset;
00387 
00388     size_t i;
00389     //We are going to add at least 20 values, to get a stable hash container while doing that
00390     //we force a large number of buckets:
00391     iumset.rehash(193);
00392 
00393     size_t nbBuckets = iumset.bucket_count();
00394     const size_t targetedBucket = nbBuckets / 2;
00395 
00396     //Lets put 10 values in the targeted bucket:
00397     for (i = 0; i < 10; ++i) {
00398       iumset.insert(targetedBucket + (i * nbBuckets));
00399     }
00400 
00401     //We put again 10 values in the targeted bucket and in reverse order:
00402     for (i = 9; i <= 10; --i) {
00403       iumset.insert(targetedBucket + (i * nbBuckets));
00404     }
00405 
00406     //Now we put some more elements until hash container is resized:
00407     i = 0;
00408     while (iumset.bucket_count() == nbBuckets) {
00409       iumset.insert(i++);
00410     }
00411 
00412     //CPPUNIT_ASSERT( iumset.bucket_size(targetedBucket) == 21 );
00413 
00414     pair<umset::iterator, umset::iterator> p = iumset.equal_range(targetedBucket);
00415     CPPUNIT_ASSERT( p.first != p.second );
00416     CPPUNIT_ASSERT( distance(p.first, p.second) == 3 );
00417 
00418     // Now we remove some elements until hash container is resized:
00419     nbBuckets = iumset.bucket_count();
00420     while (iumset.bucket_count() == nbBuckets &&
00421            !iumset.empty()) {
00422       iumset.erase(iumset.begin());
00423     }
00424     CPPUNIT_ASSERT( iumset.load_factor() <= iumset.max_load_factor() );
00425 
00426     // Adding an element back shouldn't change number of buckets:
00427     nbBuckets = iumset.bucket_count();
00428     iumset.insert(0);
00429     CPPUNIT_ASSERT( iumset.bucket_count() == nbBuckets );
00430   }
00431 
00432   {
00433     srand(0);
00434     for (int runs = 0; runs < 2; ++runs) {
00435       size_t magic = rand();
00436       umset hum;
00437       size_t c = 0;
00438       for (int i = 0; i < 10000; ++i) {
00439         if ((rand() % 500) == 0) {
00440           hum.insert(magic);
00441           ++c;
00442         }
00443         else {
00444           size_t r;
00445           while ((r = rand()) == magic)
00446             ;
00447           hum.insert(r);
00448         }
00449 
00450         /*
00451         if ((float)(hum.size() + 1) / (float)hum.bucket_count() > hum.max_load_factor()) {
00452           cout << "Hash container dump: Nb elems: " << hum.size() << ", Nb buckets: " << hum.bucket_count() << "\n";
00453           for (size_t b = 0; b < hum.bucket_count(); ++b) {
00454             if (hum.bucket_size(b) != 0) {
00455               umset::local_iterator litBegin(hum.begin(b)), litEnd(hum.end(b));
00456               cout << "B" << b << ": ";
00457               for (umset::local_iterator lit = litBegin; lit != litEnd; ++lit) {
00458                 if (lit != litBegin) {
00459                   cout << " - ";
00460                 }
00461                 cout << *lit;
00462               }
00463               cout << "\n";
00464             }
00465           }
00466           cout << endl;
00467         }
00468         */
00469       }
00470       CPPUNIT_ASSERT( hum.count(magic) == c );
00471     }
00472   }
00473 #endif
00474 }
00475 
00476 void UnorderedTest::benchmark1()
00477 {
00478 #if defined (STLPORT)
00479   typedef unordered_multiset<size_t> umset;
00480 
00481   const size_t target = 500000;
00482   umset iumset;
00483   iumset.max_load_factor(10);
00484   size_t i;
00485   for (i = 0; i < target; ++i) {
00486     iumset.insert(i);
00487   }
00488 
00489   for (i = 0; i < target; ++i) {
00490     iumset.erase(i);
00491   }
00492 #endif
00493 }
00494 
00495 void UnorderedTest::benchmark2()
00496 {
00497 #if defined (STLPORT)
00498   typedef unordered_multiset<size_t> umset;
00499 
00500   const size_t target = 500000;
00501   umset iumset;
00502   iumset.max_load_factor(10);
00503   size_t i;
00504   for (i = 0; i < target; ++i) {
00505     iumset.insert(target - i);
00506   }
00507 
00508   for (i = 0; i < target; ++i) {
00509     iumset.erase(target - i);
00510   }
00511 #endif
00512 }
00513 
00514 struct Key
00515 {
00516   Key() : m_data(0) {}
00517   explicit Key(int data) : m_data(data) {}
00518 
00519   int m_data;
00520 
00521 #if defined (__DMC__) // slist<_Tp,_Alloc>::remove error
00522   bool operator==(const Key&) const;
00523 #endif
00524 };
00525 
00526 struct KeyHash
00527 {
00528   size_t operator () (Key key) const
00529   { return (size_t)key.m_data; }
00530 
00531   size_t operator () (int data) const
00532   { return (size_t)data; }
00533 };
00534 
00535 struct KeyEqual
00536 {
00537   bool operator () (Key lhs, Key rhs) const
00538   { return lhs.m_data == rhs.m_data; }
00539 
00540   bool operator () (Key lhs, int rhs) const
00541   { return lhs.m_data == rhs; }
00542 
00543   bool operator () (int lhs, Key rhs) const
00544   { return lhs == rhs.m_data; }
00545 };
00546 
00547 struct KeyHashPtr
00548 {
00549   size_t operator () (Key const volatile *key) const
00550   { return (size_t)key->m_data; }
00551 
00552   size_t operator () (int data) const
00553   { return (size_t)data; }
00554 };
00555 
00556 struct KeyEqualPtr
00557 {
00558   bool operator () (Key const volatile *lhs, Key const volatile *rhs) const
00559   { return lhs->m_data == rhs->m_data; }
00560 
00561   bool operator () (Key const volatile *lhs, int rhs) const
00562   { return lhs->m_data == rhs; }
00563 
00564   bool operator () (int lhs, Key const volatile *rhs) const
00565   { return lhs == rhs->m_data; }
00566 };
00567 
00568 void UnorderedTest::template_methods()
00569 {
00570 #if defined (STLPORT) && defined (_STLP_USE_CONTAINERS_EXTENSION)
00571   {
00572     typedef unordered_set<Key, KeyHash, KeyEqual> Container;
00573     Container cont;
00574     cont.insert(Key(1));
00575     cont.insert(Key(2));
00576     cont.insert(Key(3));
00577     cont.insert(Key(4));
00578 
00579     CPPUNIT_ASSERT( cont.count(Key(1)) == 1 );
00580     CPPUNIT_ASSERT( cont.count(1) == 1 );
00581     CPPUNIT_ASSERT( cont.count(5) == 0 );
00582 
00583     CPPUNIT_ASSERT( cont.find(2) != cont.end() );
00584     CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
00585 
00586     Container const& ccont = cont;
00587     CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
00588     CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
00589     CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
00590   }
00591 
00592   {
00593     typedef unordered_set<Key*, KeyHashPtr, KeyEqualPtr> Container;
00594     Container cont;
00595     Key key1(1), key2(2), key3(3), key4(4);
00596     cont.insert(&key1);
00597     cont.insert(&key2);
00598     cont.insert(&key3);
00599     cont.insert(&key4);
00600 
00601     CPPUNIT_ASSERT( cont.count(1) == 1 );
00602     CPPUNIT_ASSERT( cont.count(5) == 0 );
00603 
00604     CPPUNIT_ASSERT( cont.find(2) != cont.end() );
00605     CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
00606 
00607     Container const& ccont = cont;
00608     CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
00609     CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
00610     CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
00611   }
00612   {
00613     typedef unordered_multiset<Key, KeyHash, KeyEqual> Container;
00614     Container cont;
00615     cont.insert(Key(1));
00616     cont.insert(Key(2));
00617     cont.insert(Key(1));
00618     cont.insert(Key(2));
00619 
00620     CPPUNIT_ASSERT( cont.count(Key(1)) == 2 );
00621     CPPUNIT_ASSERT( cont.count(1) == 2 );
00622     CPPUNIT_ASSERT( cont.count(5) == 0 );
00623 
00624     CPPUNIT_ASSERT( cont.find(2) != cont.end() );
00625     CPPUNIT_ASSERT( cont.equal_range(1) != make_pair(cont.end(), cont.end()) );
00626 
00627     Container const& ccont = cont;
00628     CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
00629     CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
00630     CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) );
00631   }
00632 
00633   {
00634     typedef unordered_multiset<Key const volatile*, KeyHashPtr, KeyEqualPtr> Container;
00635     Container cont;
00636     Key key1(1), key2(2), key3(3), key4(4);
00637     cont.insert(&key1);
00638     cont.insert(&key2);
00639     cont.insert(&key3);
00640     cont.insert(&key4);
00641 
00642     CPPUNIT_ASSERT( cont.count(1) == 1 );
00643     CPPUNIT_ASSERT( cont.count(5) == 0 );
00644 
00645     CPPUNIT_ASSERT( cont.find(2) != cont.end() );
00646     CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
00647 
00648     Container const& ccont = cont;
00649     CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
00650     CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
00651     CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
00652   }
00653 #endif
00654 }
00655 
00656 #if defined (STLPORT) && \
00657     (!defined (_STLP_USE_PTR_SPECIALIZATIONS) || defined (_STLP_CLASS_PARTIAL_SPECIALIZATION))
00658 #  if !defined (__DMC__)
00659 /* Simple compilation test: Check that nested types like iterator
00660  * can be access even if type used to instanciate container is not
00661  * yet completely defined.
00662  */
00663 class IncompleteClass
00664 {
00665   unordered_set<IncompleteClass> usinstances;
00666   typedef unordered_set<IncompleteClass>::iterator usit;
00667   unordered_multiset<IncompleteClass> usminstances;
00668   typedef unordered_multiset<IncompleteClass>::iterator usmit;
00669 
00670   unordered_map<IncompleteClass, IncompleteClass> uminstances;
00671   typedef unordered_map<IncompleteClass, IncompleteClass>::iterator umit;
00672   unordered_multimap<IncompleteClass, IncompleteClass> umminstances;
00673   typedef unordered_multimap<IncompleteClass, IncompleteClass>::iterator ummit;
00674 };
00675 #  endif
00676 #endif

Generated on Sun May 27 2012 04:35:54 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.