Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentest_slist.cpp
Go to the documentation of this file.
00001 /*********************************************************************************** 00002 test_slist.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 #if defined( EH_SLIST_IMPLEMENTED ) 00018 # include "TestClass.h" 00019 # include "LeakCheck.h" 00020 # if defined (EH_NEW_HEADERS) && defined (EH_USE_SGI_STL) 00021 # include <slist> 00022 # else 00023 # include <slist.h> 00024 # endif 00025 #include "test_construct.h" 00026 #include "test_assign_op.h" 00027 #include "test_push_back.h" 00028 #include "test_insert.h" 00029 #include "test_push_front.h" 00030 00031 #if defined (__GNUC__) && defined (__APPLE__) 00032 typedef EH_STD::slist<TestClass, eh_allocator(TestClass) > TestSList; 00033 #else 00034 typedef EH_STD::__slist__<TestClass, eh_allocator(TestClass) > TestSList; 00035 #endif 00036 00037 inline sequence_container_tag 00038 container_category(const TestSList&) { 00039 return sequence_container_tag(); 00040 } 00041 00042 struct test_slist_sort { 00043 test_slist_sort() { 00044 gTestController.SetCurrentTestName("slist::sort()"); 00045 } 00046 void operator()( TestSList& slist ) const { 00047 slist.sort(); 00048 for ( TestSList::iterator p = slist.begin(), q; p != slist.end(); q = p, p++ ) 00049 if ( p != slist.begin() ) { 00050 EH_ASSERT( *p >= *q ); 00051 } 00052 } 00053 }; 00054 00055 void test_slist() { 00056 TestSList testSList, testSList2; 00057 size_t slistSize = random_number(random_base); 00058 00059 while (testSList.size() < slistSize) { 00060 TestClass x; 00061 testSList.push_front( x ); 00062 testSList2.push_front( TestClass() ); 00063 } 00064 00065 StrongCheck( testSList, test_insert_one<TestSList>(testSList) ); 00066 StrongCheck( testSList, test_insert_one<TestSList>(testSList, 0) ); 00067 StrongCheck( testSList, test_insert_one<TestSList>(testSList, (int)testSList.size()) ); 00068 00069 WeakCheck( testSList, test_insert_n<TestSList>(testSList, random_number(random_base) ) ); 00070 WeakCheck( testSList, test_insert_n<TestSList>(testSList, random_number(random_base), 0 ) ); 00071 WeakCheck( testSList, test_insert_n<TestSList>(testSList, random_number(random_base), (int)testSList.size() ) ); 00072 00073 size_t insCnt = random_number(random_base); 00074 TestClass *insFirst = new TestSList::value_type[1+insCnt]; 00075 WeakCheck( testSList, insert_range_tester(testSList, insFirst, insFirst+insCnt) ); 00076 00077 ConstCheck( 0, test_construct_pointer_range<TestSList>(insFirst, insFirst+insCnt) ); 00078 delete[] insFirst; 00079 WeakCheck( testSList, test_insert_range<TestSList,TestSList::iterator>(testSList, testSList2.begin(), testSList2.end() ) ); 00080 StrongCheck( testSList, test_push_front<TestSList>(testSList) ); 00081 StrongCheck( testSList, test_slist_sort() ); // Simply to verify strength. 00082 00083 ConstCheck( 0, test_default_construct<TestSList>() ); 00084 ConstCheck( 0, test_construct_n<TestSList>( random_number(random_base) ) ); 00085 ConstCheck( 0, test_construct_n_instance<TestSList>( random_number(random_base) ) ); 00086 ConstCheck( 0, test_construct_iter_range<TestSList>( testSList2 ) ); 00087 ConstCheck( testSList, test_copy_construct<TestSList>() ); 00088 WeakCheck( testSList, test_assign_op<TestSList>( testSList2 ) ); 00089 } 00090 00091 #endif // EH_SLIST_IMPLEMENTED Generated on Sat May 26 2012 04:34:08 for ReactOS by
1.7.6.1
|