sl@0: /*********************************************************************************** sl@0: test_hash_map.cpp sl@0: sl@0: * Copyright (c) 1997 sl@0: * Mark of the Unicorn, Inc. sl@0: * sl@0: * Permission to use, copy, modify, distribute and sell this software sl@0: * and its documentation for any purpose is hereby granted without fee, sl@0: * provided that the above copyright notice appear in all copies and sl@0: * that both that copyright notice and this permission notice appear sl@0: * in supporting documentation. Mark of the Unicorn makes no sl@0: * representations about the suitability of this software for any sl@0: * purpose. It is provided "as is" without express or implied warranty. sl@0: sl@0: ***********************************************************************************/ sl@0: #include "Tests.h" sl@0: #if defined( EH_HASHED_CONTAINERS_IMPLEMENTED ) sl@0: #include "TestClass.h" sl@0: #include "LeakCheck.h" sl@0: sl@0: # include sl@0: sl@0: #include "test_construct.h" sl@0: #include "test_assign_op.h" sl@0: #include "test_push_back.h" sl@0: #include "test_insert.h" sl@0: #include "test_push_front.h" sl@0: #include "ThrowCompare.h" sl@0: #include "test_hash_resize.h" sl@0: /* sl@0: template struct pair; sl@0: template struct __hashtable_node >; sl@0: template class hash_map; sl@0: template class hash_multimap; sl@0: */ sl@0: sl@0: typedef EH_STD::__hash_multimap__ TestMultiMap; sl@0: sl@0: sl@0: inline multimap_tag sl@0: container_category(const TestMultiMap&) { sl@0: return multimap_tag(); sl@0: } sl@0: sl@0: void test_hash_multimap() { sl@0: # if !(defined (_MSC_VER) && (_MSC_VER < 1100)) sl@0: TestMultiMap testMultiMap, testMultiMap2; sl@0: sl@0: const size_t hash_mapSize = random_number(random_base); sl@0: sl@0: while ( testMultiMap.size() < hash_mapSize ) sl@0: { sl@0: TestMultiMap::value_type x; sl@0: testMultiMap.insert( x ); sl@0: testMultiMap2.insert( TestMultiMap::value_type() ); sl@0: } sl@0: sl@0: # if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE ) sl@0: WeakCheck( testMultiMap, test_hash_resize() ); sl@0: // TestMultiMap == TestMultiMap: no such operator! - ptr sl@0: // StrongCheck( testMultiMap, test_insert_noresize(testMultiMap) ); sl@0: # endif sl@0: WeakCheck( testMultiMap, test_insert_value(testMultiMap) ); sl@0: sl@0: size_t insCnt = random_number(random_base); sl@0: TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[1+insCnt]; sl@0: WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) ); sl@0: ConstCheck( 0, test_construct_pointer_range(insFirst, insFirst+insCnt) ); sl@0: delete[] insFirst; sl@0: sl@0: WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) ); sl@0: sl@0: ConstCheck( 0, test_default_construct() ); sl@0: # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION sl@0: ConstCheck( 0, test_construct_iter_range_n( testMultiMap2 ) ); sl@0: # endif sl@0: ConstCheck( testMultiMap, test_copy_construct() ); sl@0: sl@0: WeakCheck( testMultiMap, test_assign_op( testMultiMap2 ) ); sl@0: # endif sl@0: } sl@0: sl@0: typedef EH_STD::__hash_map__ TestMap; sl@0: sl@0: inline map_tag sl@0: container_category(const TestMap&) sl@0: { sl@0: return map_tag(); sl@0: } sl@0: sl@0: void test_hash_map() sl@0: { sl@0: # if !(defined (_MSC_VER) && (_MSC_VER < 1100)) sl@0: TestMap testMap, testMap2; sl@0: sl@0: const size_t hash_mapSize = random_number(random_base); sl@0: sl@0: while ( testMap.size() < hash_mapSize ) { sl@0: TestMap::value_type x; sl@0: testMap.insert( x ); sl@0: testMap2.insert( TestMap::value_type() ); sl@0: } sl@0: sl@0: #if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE ) sl@0: WeakCheck( testMap, test_hash_resize() ); sl@0: // TestMultiMap == TestMultiMap: no such operator! - ptr sl@0: // StrongCheck( testMap, test_insert_noresize(testMap) ); sl@0: #endif sl@0: WeakCheck( testMap, test_insert_value(testMap) ); sl@0: sl@0: size_t insCnt = random_number(random_base); sl@0: TestMap::value_type *insFirst = new TestMap::value_type[1+insCnt]; sl@0: WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) ); sl@0: ConstCheck( 0, test_construct_pointer_range(insFirst, insFirst+insCnt) ); sl@0: delete[] insFirst; sl@0: sl@0: WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) ); sl@0: sl@0: ConstCheck( 0, test_default_construct() ); sl@0: # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION sl@0: ConstCheck( 0, test_construct_iter_range_n( testMap2 ) ); sl@0: # endif sl@0: ConstCheck( testMap, test_copy_construct() ); sl@0: sl@0: WeakCheck( testMap, test_assign_op( testMap2 ) ); sl@0: # endif sl@0: } sl@0: sl@0: #endif // EH_HASHED_CONTAINERS_IMPLEMENTED