1 /***********************************************************************************
5 * Mark of the Unicorn, Inc.
7 * Permission to use, copy, modify, distribute and sell this software
8 * and its documentation for any purpose is hereby granted without fee,
9 * provided that the above copyright notice appear in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation. Mark of the Unicorn makes no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
15 ***********************************************************************************/
17 #if defined( EH_HASHED_CONTAINERS_IMPLEMENTED )
18 #include "TestClass.h"
19 #include "LeakCheck.h"
23 #include "test_construct.h"
24 #include "test_assign_op.h"
25 #include "test_push_back.h"
26 #include "test_insert.h"
27 #include "test_push_front.h"
28 #include "ThrowCompare.h"
29 #include "test_hash_resize.h"
31 template struct pair<const TestClass, TestClass>;
32 template struct __hashtable_node<pair<const TestClass, TestClass> >;
33 template class hash_map<TestClass, TestClass, ThrowHash, ThrowEqual>;
34 template class hash_multimap<TestClass, TestClass, ThrowHash, ThrowEqual>;
37 typedef EH_STD::__hash_multimap__
<TestClass
, TestClass
, ThrowHash
, ThrowEqual
,
38 eh_allocator(TestClass
) > TestMultiMap
;
42 container_category(const TestMultiMap
&) {
43 return multimap_tag();
46 void test_hash_multimap() {
47 # if !(defined (_MSC_VER) && (_MSC_VER < 1100))
48 TestMultiMap testMultiMap
, testMultiMap2
;
50 const size_t hash_mapSize
= random_number(random_base
);
52 while ( testMultiMap
.size() < hash_mapSize
)
54 TestMultiMap::value_type x
;
55 testMultiMap
.insert( x
);
56 testMultiMap2
.insert( TestMultiMap::value_type() );
59 # if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
60 WeakCheck( testMultiMap
, test_hash_resize
<TestMultiMap
>() );
61 // TestMultiMap == TestMultiMap: no such operator! - ptr
62 // StrongCheck( testMultiMap, test_insert_noresize<TestMultiMap>(testMultiMap) );
64 WeakCheck( testMultiMap
, test_insert_value
<TestMultiMap
>(testMultiMap
) );
66 size_t insCnt
= random_number(random_base
);
67 TestMultiMap::value_type
*insFirst
= new TestMultiMap::value_type
[1+insCnt
];
68 WeakCheck( testMultiMap
, insert_range_tester(testMultiMap
, insFirst
, insFirst
+insCnt
) );
69 ConstCheck( 0, test_construct_pointer_range
<TestMultiMap
>(insFirst
, insFirst
+insCnt
) );
72 WeakCheck( testMultiMap
, insert_range_tester(testMultiMap
, testMultiMap2
.begin(), testMultiMap2
.end() ) );
74 ConstCheck( 0, test_default_construct
<TestMultiMap
>() );
75 # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
76 ConstCheck( 0, test_construct_iter_range_n
<TestMultiMap
>( testMultiMap2
) );
78 ConstCheck( testMultiMap
, test_copy_construct
<TestMultiMap
>() );
80 WeakCheck( testMultiMap
, test_assign_op
<TestMultiMap
>( testMultiMap2
) );
84 typedef EH_STD::__hash_map__
<TestClass
, TestClass
, ThrowHash
,
85 ThrowEqual
, eh_allocator(TestClass
) > TestMap
;
88 container_category(const TestMap
&)
95 # if !(defined (_MSC_VER) && (_MSC_VER < 1100))
96 TestMap testMap
, testMap2
;
98 const size_t hash_mapSize
= random_number(random_base
);
100 while ( testMap
.size() < hash_mapSize
) {
101 TestMap::value_type x
;
103 testMap2
.insert( TestMap::value_type() );
106 #if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
107 WeakCheck( testMap
, test_hash_resize
<TestMap
>() );
108 // TestMultiMap == TestMultiMap: no such operator! - ptr
109 // StrongCheck( testMap, test_insert_noresize<TestMap>(testMap) );
111 WeakCheck( testMap
, test_insert_value
<TestMap
>(testMap
) );
113 size_t insCnt
= random_number(random_base
);
114 TestMap::value_type
*insFirst
= new TestMap::value_type
[1+insCnt
];
115 WeakCheck( testMap
, insert_range_tester(testMap
, insFirst
, insFirst
+insCnt
) );
116 ConstCheck( 0, test_construct_pointer_range
<TestMap
>(insFirst
, insFirst
+insCnt
) );
119 WeakCheck( testMap
, insert_range_tester(testMap
, testMap2
.begin(), testMap2
.end() ) );
121 ConstCheck( 0, test_default_construct
<TestMap
>() );
122 # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
123 ConstCheck( 0, test_construct_iter_range_n
<TestMap
>( testMap2
) );
125 ConstCheck( testMap
, test_copy_construct
<TestMap
>() );
127 WeakCheck( testMap
, test_assign_op
<TestMap
>( testMap2
) );
131 #endif // EH_HASHED_CONTAINERS_IMPLEMENTED