First public contribution.
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 #include "TestClass.h"
18 #include "LeakCheck.h"
19 # if defined (EH_NEW_HEADERS)
26 #include "test_construct.h"
27 #include "test_assign_op.h"
28 #include "test_push_back.h"
29 #include "test_insert.h"
30 #include "test_push_front.h"
31 #include "ThrowCompare.h"
32 #include "test_insert.h"
34 template <class K, class V, class Comp, class A>
36 container_category(const EH_STD::__multimap__<K,V,Comp, A>&)
38 return multimap_tag();
41 template <class K, class V, class Comp, class A >
43 container_category(const EH_STD::__map__<K,V,Comp, A>&)
48 typedef EH_STD::__multimap__<TestClass, TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiMap;
52 TestMultiMap testMultiMap, testMultiMap2;
54 const size_t mapSize = random_number(random_base);
56 while ( testMultiMap.size() < mapSize )
58 TestMultiMap::value_type x;
59 testMultiMap.insert( x );
60 testMultiMap2.insert( TestMultiMap::value_type() );
63 StrongCheck( testMultiMap, test_insert_value<TestMultiMap>(testMultiMap) );
65 size_t insCnt = 1 + random_number(random_base);
66 TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[insCnt];
68 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) );
70 ConstCheck( 0, test_construct_pointer_range<TestMultiMap>(insFirst, insFirst+insCnt) );
74 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) );
77 ConstCheck( 0, test_default_construct<TestMultiMap>() );
79 ConstCheck( 0, test_construct_iter_range<TestMultiMap>( testMultiMap2 ) );
81 ConstCheck( testMultiMap, test_copy_construct<TestMultiMap>() );
83 WeakCheck( testMultiMap, test_assign_op<TestMultiMap>( testMultiMap2 ) );
86 typedef EH_STD::__map__<TestClass, TestClass, ThrowCompare, eh_allocator(TestClass) > TestMap;
88 void CheckInvariant( const TestMap& m );
90 void CheckInvariant( const TestMap& m )
92 // assert( map.__rb_verify() );
94 EH_DISTANCE( m.begin(), m.end(), total );
95 assert( m.size() == total );
100 TestMap testMap, testMap2;
102 const size_t mapSize = random_number(random_base);
104 while ( testMap.size() < mapSize )
106 TestMap::value_type x;
108 testMap2.insert( TestMap::value_type() );
111 StrongCheck( 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];
116 WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );
118 ConstCheck( 0, test_construct_pointer_range<TestMap>(insFirst, insFirst+insCnt) );
121 WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) );
122 ConstCheck( 0, test_default_construct<TestMap>() );
123 ConstCheck( 0, test_construct_iter_range<TestMap>( testMap2 ) );
124 ConstCheck( testMap, test_copy_construct<TestMap>() );
125 WeakCheck( testMap, test_assign_op<TestMap>( testMap2 ) );