Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentest_deque.cpp
Go to the documentation of this file.
00001 /*********************************************************************************** 00002 test_deque.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 00017 #include "Tests.h" 00018 # if defined (EH_NEW_HEADERS) 00019 # ifdef __SUNPRO_CC 00020 # include <stdio.h> 00021 # else 00022 # include <cstdio> 00023 # endif 00024 # include <deque> 00025 # else 00026 # include <stdio.h> 00027 # include <deque.h> 00028 # endif 00029 #include "TestClass.h" 00030 #include "LeakCheck.h" 00031 #include "test_construct.h" 00032 #include "test_assign_op.h" 00033 #include "test_push_back.h" 00034 #include "test_insert.h" 00035 #include "test_push_front.h" 00036 00037 typedef TestClass DQTestClass; 00038 00039 typedef EH_STD::deque<DQTestClass, eh_allocator(DQTestClass) > TestDeque; 00040 00041 inline sequence_container_tag 00042 container_category(const TestDeque&) 00043 { 00044 return sequence_container_tag(); 00045 } 00046 00047 void test_deque() 00048 { 00049 size_t dequeSize = random_number(random_base); 00050 TestDeque emptyDeque; 00051 TestDeque testDeque, testDeque2; 00052 while ( testDeque.size() < dequeSize ) 00053 { 00054 DQTestClass x; 00055 testDeque.push_back( x ); 00056 testDeque2.push_back( DQTestClass() ); 00057 } 00058 00059 ConstCheck( testDeque, test_copy_construct<TestDeque>() ); 00060 WeakCheck( testDeque, test_insert_one<TestDeque>(testDeque) ); 00061 StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque, 0) ); 00062 StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque, (int)testDeque.size()) ); 00063 00064 WeakCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base) ) ); 00065 StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), 0 ) ); 00066 StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), (int)testDeque.size() ) ); 00067 00068 size_t insCnt = random_number(random_base); 00069 DQTestClass *insFirst = new TestDeque::value_type[insCnt + 1]; 00070 00071 WeakCheck( testDeque, insert_range_tester(testDeque, insFirst, insFirst + insCnt) ); 00072 StrongCheck( testDeque, insert_range_at_begin_tester(testDeque, insFirst, insFirst + insCnt) ); 00073 StrongCheck( testDeque, insert_range_at_end_tester(testDeque, insFirst, insFirst + insCnt) ); 00074 00075 ConstCheck( 0, test_construct_pointer_range<TestDeque>(insFirst, insFirst + insCnt) ); 00076 delete[] insFirst; 00077 00078 WeakCheck( testDeque, insert_range_tester(testDeque, testDeque2.begin(), testDeque2.end() ) ); 00079 00080 StrongCheck( testDeque, test_push_back<TestDeque>(testDeque) ); 00081 StrongCheck( emptyDeque, test_push_back<TestDeque>(emptyDeque) ); 00082 StrongCheck( testDeque, test_push_front<TestDeque>(testDeque) ); 00083 StrongCheck( emptyDeque, test_push_front<TestDeque>(emptyDeque) ); 00084 00085 00086 ConstCheck( 0, test_default_construct<TestDeque>() ); 00087 ConstCheck( 0, test_construct_n<TestDeque>( random_number(random_base) ) ); 00088 ConstCheck( 0, test_construct_n_instance<TestDeque>( random_number(random_base) ) ); 00089 ConstCheck( 0, test_construct_iter_range<TestDeque>( testDeque2 ) ); 00090 00091 testDeque2.resize( testDeque.size() * 3 / 2 ); 00092 WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) ); 00093 testDeque2.resize( testDeque.size() * 2 / 3 ); 00094 WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) ); 00095 } Generated on Sun May 27 2012 04:35:15 for ReactOS by
1.7.6.1
|