Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentest_map.cpp
Go to the documentation of this file.
00001 /*********************************************************************************** 00002 test_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 #include "TestClass.h" 00018 #include "LeakCheck.h" 00019 # if defined (EH_NEW_HEADERS) 00020 #include <map> 00021 # else 00022 #include <multimap.h> 00023 #include <map.h> 00024 # endif 00025 00026 #include "test_construct.h" 00027 #include "test_assign_op.h" 00028 #include "test_push_back.h" 00029 #include "test_insert.h" 00030 #include "test_push_front.h" 00031 #include "ThrowCompare.h" 00032 #include "test_insert.h" 00033 00034 template <class K, class V, class Comp, class A> 00035 inline multimap_tag 00036 container_category(const EH_STD::__multimap__<K,V,Comp, A>&) 00037 { 00038 return multimap_tag(); 00039 } 00040 00041 template <class K, class V, class Comp, class A > 00042 inline map_tag 00043 container_category(const EH_STD::__map__<K,V,Comp, A>&) 00044 { 00045 return map_tag(); 00046 } 00047 00048 typedef EH_STD::__multimap__<TestClass, TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiMap; 00049 00050 void test_multimap() 00051 { 00052 TestMultiMap testMultiMap, testMultiMap2; 00053 00054 const size_t mapSize = random_number(random_base); 00055 00056 while ( testMultiMap.size() < mapSize ) 00057 { 00058 TestMultiMap::value_type x; 00059 testMultiMap.insert( x ); 00060 testMultiMap2.insert( TestMultiMap::value_type() ); 00061 } 00062 00063 StrongCheck( testMultiMap, test_insert_value<TestMultiMap>(testMultiMap) ); 00064 00065 size_t insCnt = 1 + random_number(random_base); 00066 TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[insCnt]; 00067 00068 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) ); 00069 00070 ConstCheck( 0, test_construct_pointer_range<TestMultiMap>(insFirst, insFirst+insCnt) ); 00071 delete[] insFirst; 00072 00073 00074 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) ); 00075 00076 00077 ConstCheck( 0, test_default_construct<TestMultiMap>() ); 00078 00079 ConstCheck( 0, test_construct_iter_range<TestMultiMap>( testMultiMap2 ) ); 00080 00081 ConstCheck( testMultiMap, test_copy_construct<TestMultiMap>() ); 00082 00083 WeakCheck( testMultiMap, test_assign_op<TestMultiMap>( testMultiMap2 ) ); 00084 } 00085 00086 typedef EH_STD::__map__<TestClass, TestClass, ThrowCompare, eh_allocator(TestClass) > TestMap; 00087 00088 void CheckInvariant( const TestMap& m ); 00089 00090 void CheckInvariant( const TestMap& m ) 00091 { 00092 // assert( map.__rb_verify() ); 00093 size_t total = 0; 00094 EH_DISTANCE( m.begin(), m.end(), total ); 00095 assert( m.size() == total ); 00096 } 00097 00098 void test_map() 00099 { 00100 TestMap testMap, testMap2; 00101 00102 const size_t mapSize = random_number(random_base); 00103 00104 while ( testMap.size() < mapSize ) 00105 { 00106 TestMap::value_type x; 00107 testMap.insert( x ); 00108 testMap2.insert( TestMap::value_type() ); 00109 } 00110 00111 StrongCheck( 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 00116 WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) ); 00117 00118 ConstCheck( 0, test_construct_pointer_range<TestMap>(insFirst, insFirst+insCnt) ); 00119 delete[] insFirst; 00120 00121 WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) ); 00122 ConstCheck( 0, test_default_construct<TestMap>() ); 00123 ConstCheck( 0, test_construct_iter_range<TestMap>( testMap2 ) ); 00124 ConstCheck( testMap, test_copy_construct<TestMap>() ); 00125 WeakCheck( testMap, test_assign_op<TestMap>( testMap2 ) ); 00126 } 00127 Generated on Sun May 27 2012 04:35:15 for ReactOS by
1.7.6.1
|