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

test_hash_map.cpp
Go to the documentation of this file.
00001 /***********************************************************************************
00002   test_hash_map.cpp
00003 
00004  * Copyright (c) 1997
00005  * Mark of the Unicorn, Inc.
00006  *
00007  * Permission to use, copy, modify, distribute and sell this software
00008  * and its documentation for any purpose is hereby granted without fee,
00009  * provided that the above copyright notice appear in all copies and
00010  * that both that copyright notice and this permission notice appear
00011  * in supporting documentation.  Mark of the Unicorn makes no
00012  * representations about the suitability of this software for any
00013  * purpose.  It is provided "as is" without express or implied warranty.
00014 
00015 ***********************************************************************************/
00016 #include "Tests.h"
00017 #if defined( EH_HASHED_CONTAINERS_IMPLEMENTED )
00018 #include "TestClass.h"
00019 #include "LeakCheck.h"
00020 
00021 #  include <hash_map>
00022 
00023 #include "test_construct.h"
00024 #include "test_assign_op.h"
00025 #include "test_push_back.h"
00026 #include "test_insert.h"
00027 #include "test_push_front.h"
00028 #include "ThrowCompare.h"
00029 #include "test_hash_resize.h"
00030 /*
00031 template struct pair<const TestClass, TestClass>;
00032 template struct __hashtable_node<pair<const TestClass, TestClass> >;
00033 template class hash_map<TestClass, TestClass, ThrowHash, ThrowEqual>;
00034 template class hash_multimap<TestClass, TestClass, ThrowHash, ThrowEqual>;
00035 */
00036 
00037 typedef EH_STD::__hash_multimap__<TestClass, TestClass, ThrowHash, ThrowEqual,
00038   eh_allocator(TestClass) > TestMultiMap;
00039 
00040 
00041 inline multimap_tag
00042 container_category(const TestMultiMap&) {
00043   return multimap_tag();
00044 }
00045 
00046 void test_hash_multimap() {
00047 # if !(defined (_MSC_VER) && (_MSC_VER < 1100))
00048   TestMultiMap testMultiMap, testMultiMap2;
00049 
00050         const size_t hash_mapSize = random_number(random_base);
00051 
00052   while ( testMultiMap.size() < hash_mapSize )
00053   {
00054     TestMultiMap::value_type x;
00055     testMultiMap.insert( x );
00056     testMultiMap2.insert( TestMultiMap::value_type() );
00057   }
00058 
00059 #  if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
00060   WeakCheck( testMultiMap, test_hash_resize<TestMultiMap>() );
00061   // TestMultiMap == TestMultiMap: no such operator! - ptr
00062   // StrongCheck( testMultiMap, test_insert_noresize<TestMultiMap>(testMultiMap) );
00063 #  endif
00064   WeakCheck( testMultiMap, test_insert_value<TestMultiMap>(testMultiMap) );
00065 
00066   size_t insCnt = random_number(random_base);
00067   TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[1+insCnt];
00068   WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) );
00069   ConstCheck( 0, test_construct_pointer_range<TestMultiMap>(insFirst, insFirst+insCnt) );
00070   delete[] insFirst;
00071 
00072   WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) );
00073 
00074   ConstCheck( 0, test_default_construct<TestMultiMap>() );
00075 #  if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
00076   ConstCheck( 0, test_construct_iter_range_n<TestMultiMap>( testMultiMap2 ) );
00077 #  endif
00078   ConstCheck( testMultiMap, test_copy_construct<TestMultiMap>() );
00079 
00080   WeakCheck( testMultiMap, test_assign_op<TestMultiMap>( testMultiMap2 ) );
00081 # endif
00082 }
00083 
00084 typedef EH_STD::__hash_map__<TestClass, TestClass, ThrowHash,
00085   ThrowEqual, eh_allocator(TestClass) > TestMap;
00086 
00087 inline map_tag
00088 container_category(const TestMap&)
00089 {
00090   return map_tag();
00091 }
00092 
00093 void test_hash_map()
00094 {
00095 # if !(defined (_MSC_VER) && (_MSC_VER < 1100))
00096   TestMap testMap, testMap2;
00097 
00098   const size_t hash_mapSize = random_number(random_base);
00099 
00100   while ( testMap.size() < hash_mapSize ) {
00101     TestMap::value_type x;
00102     testMap.insert( x );
00103     testMap2.insert( TestMap::value_type() );
00104   }
00105 
00106 #if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
00107   WeakCheck( testMap, test_hash_resize<TestMap>() );
00108   // TestMultiMap == TestMultiMap: no such operator! - ptr
00109   // StrongCheck( testMap, test_insert_noresize<TestMap>(testMap) );
00110 #endif
00111   WeakCheck( testMap, test_insert_value<TestMap>(testMap) );
00112 
00113   size_t insCnt = random_number(random_base);
00114   TestMap::value_type *insFirst = new TestMap::value_type[1+insCnt];
00115   WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );
00116   ConstCheck( 0, test_construct_pointer_range<TestMap>(insFirst, insFirst+insCnt) );
00117   delete[] insFirst;
00118 
00119   WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) );
00120 
00121   ConstCheck( 0, test_default_construct<TestMap>() );
00122 #  if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
00123   ConstCheck( 0, test_construct_iter_range_n<TestMap>( testMap2 ) );
00124 #  endif
00125   ConstCheck( testMap, test_copy_construct<TestMap>() );
00126 
00127   WeakCheck( testMap, test_assign_op<TestMap>( testMap2 ) );
00128 # endif
00129 }
00130 
00131 #endif  // EH_HASHED_CONTAINERS_IMPLEMENTED

Generated on Wed May 23 2012 04:33:07 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.