Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentest_hash_set.cpp
Go to the documentation of this file.
00001 /*********************************************************************************** 00002 test_hash_set.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 00018 #if defined( EH_HASHED_CONTAINERS_IMPLEMENTED ) 00019 00020 # include <hash_set> 00021 00022 #include "TestClass.h" 00023 #include "LeakCheck.h" 00024 #include "test_construct.h" 00025 #include "test_assign_op.h" 00026 #include "test_push_back.h" 00027 #include "test_insert.h" 00028 #include "test_push_front.h" 00029 #include "ThrowCompare.h" 00030 #include "test_hash_resize.h" 00031 00032 typedef EH_STD::__hash_multiset__<TestClass, ThrowHash, ThrowEqual, 00033 eh_allocator(TestClass) > TestMultiSet; 00034 00035 inline multiset_tag 00036 container_category(const TestMultiSet&) 00037 { 00038 return multiset_tag(); 00039 } 00040 00041 void test_hash_multiset() 00042 { 00043 # if !(defined (_MSC_VER) && (_MSC_VER < 1100)) 00044 TestMultiSet testMultiSet, testMultiSet2; 00045 00046 const size_t hash_setSize = random_number(random_base); 00047 00048 while ( testMultiSet.size() < hash_setSize ) 00049 { 00050 TestMultiSet::value_type x; 00051 testMultiSet.insert( x ); 00052 testMultiSet2.insert( TestMultiSet::value_type() ); 00053 } 00054 00055 # if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE ) 00056 WeakCheck( testMultiSet, test_hash_resize<TestMultiSet>() ); 00057 // TestMultiSet == TestMultiSet: no such operator! - ptr 00058 // StrongCheck( testMultiSet, test_insert_noresize<TestMultiSet>(testMultiSet) ); 00059 # endif 00060 WeakCheck( testMultiSet, test_insert_value<TestMultiSet>(testMultiSet) ); 00061 00062 size_t insCnt = random_number(random_base); 00063 TestMultiSet::value_type *insFirst = new TestMultiSet::value_type[1+insCnt]; 00064 WeakCheck( testMultiSet, insert_range_tester(testMultiSet, insFirst, insFirst+insCnt) ); 00065 ConstCheck( 0, test_construct_pointer_range<TestMultiSet>(insFirst, insFirst+insCnt) ); 00066 delete[] insFirst; 00067 00068 WeakCheck( testMultiSet, insert_range_tester(testMultiSet, testMultiSet2.begin(), testMultiSet2.end() ) ); 00069 00070 ConstCheck( 0, test_default_construct<TestMultiSet>() ); 00071 # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION 00072 ConstCheck( 0, test_construct_iter_range_n<TestMultiSet>( testMultiSet2 ) ); 00073 # endif 00074 ConstCheck( testMultiSet, test_copy_construct<TestMultiSet>() ); 00075 00076 WeakCheck( testMultiSet, test_assign_op<TestMultiSet>( testMultiSet2 ) ); 00077 # endif 00078 } 00079 00080 typedef EH_STD::__hash_set__<TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestSet; 00081 00082 inline set_tag 00083 container_category(const TestSet&) 00084 { 00085 return set_tag(); 00086 } 00087 00088 void test_hash_set() 00089 { 00090 # if !(defined (_MSC_VER) && (_MSC_VER < 1100)) 00091 TestSet testSet, testSet2; 00092 00093 const size_t hash_setSize = random_number(random_base); 00094 00095 while ( testSet.size() < hash_setSize ) 00096 { 00097 TestSet::value_type x; 00098 testSet.insert( x ); 00099 testSet2.insert( TestSet::value_type() ); 00100 } 00101 00102 # if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE ) 00103 WeakCheck( testSet, test_hash_resize<TestSet>() ); 00104 // TestMultiSet == TestMultiSet: no such operator! - ptr 00105 // StrongCheck( testSet, test_insert_noresize<TestSet>(testSet) ); 00106 # endif 00107 WeakCheck( testSet, test_insert_value<TestSet>(testSet) ); 00108 00109 size_t insCnt = random_number(random_base); 00110 TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt]; 00111 WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) ); 00112 ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) ); 00113 delete[] insFirst; 00114 00115 WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) ); 00116 00117 ConstCheck( 0, test_default_construct<TestSet>() ); 00118 # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION 00119 ConstCheck( 0, test_construct_iter_range_n<TestSet>( testSet2 ) ); 00120 # endif 00121 ConstCheck( testSet, test_copy_construct<TestSet>() ); 00122 00123 WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) ); 00124 # endif 00125 } 00126 00127 #endif // EH_HASHED_CONTAINERS_IMPLEMENTED Generated on Sat May 26 2012 04:34:05 for ReactOS by
1.7.6.1
|