ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

test_list.cpp
Go to the documentation of this file.
00001 /***********************************************************************************
00002   test_list.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 <list>
00021 #else
00022 #include <list.h>
00023 #endif
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 "nc_alloc.h"
00030 
00031 typedef EH_STD::__list__<TestClass, eh_allocator(TestClass) > TestList;
00032 
00033 inline sequence_container_tag
00034 container_category(const TestList&)
00035 {
00036   return sequence_container_tag();
00037 }
00038 
00039 //
00040 //  list sort() member test operation. Does not verify stability.
00041 //
00042 struct test_list_sort
00043 {
00044     test_list_sort()
00045     {
00046         gTestController.SetCurrentTestName("list::sort()");
00047     }
00048 
00049     void operator()( TestList& list ) const
00050     {
00051         list.sort();
00052 
00053         gTestController.CancelFailureCountdown();
00054 
00055         for ( TestList::iterator p = list.begin(); p != list.end(); p++ )
00056             if ( p != list.begin() ) {
00057                 TestList::iterator tmp=p;
00058                 --tmp;
00059                 EH_ASSERT( *p >= *tmp );
00060             }
00061     }
00062 };
00063 
00064 void test_list()
00065 {
00066     TestList testList, testList2;
00067     size_t listSize = random_number(random_base);
00068 
00069     while ( testList.size() < listSize )
00070     {
00071         TestClass x;
00072         testList.push_back( x );
00073         testList2.push_back( TestClass() );
00074     }
00075 
00076     StrongCheck( testList, test_insert_one<TestList>(testList) );
00077     StrongCheck( testList, test_insert_one<TestList>(testList, 0) );
00078     StrongCheck( testList, test_insert_one<TestList>(testList, (int)testList.size()) );
00079 
00080     WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base) ) );
00081     WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base), 0 ) );
00082     WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base), (int)testList.size() ) );
00083 
00084     size_t insCnt = random_number(random_base);
00085     TestClass *insFirst = new TestList::value_type[1+insCnt];
00086 
00087     WeakCheck( testList, insert_range_tester(testList, insFirst, insFirst+insCnt) );
00088     WeakCheck( testList, insert_range_at_begin_tester(testList, insFirst, insFirst+insCnt) );
00089     WeakCheck( testList, insert_range_at_end_tester(testList, insFirst, insFirst+insCnt) );
00090 
00091     ConstCheck( 0, test_construct_pointer_range<TestList>(insFirst, insFirst+insCnt) );
00092     delete[] insFirst;
00093 
00094     WeakCheck( testList, insert_range_tester(testList, testList2.begin(), testList2.end() ) );
00095 
00096     StrongCheck( testList, test_push_front<TestList>(testList) );
00097     StrongCheck( testList, test_push_back<TestList>(testList) );
00098 
00099     StrongCheck( testList, test_list_sort() );  // Simply to verify strength.
00100 
00101     ConstCheck( 0, test_default_construct<TestList>() );
00102     ConstCheck( 0, test_construct_n<TestList>( random_number(random_base) ) );
00103     ConstCheck( 0, test_construct_n_instance<TestList>( random_number(random_base) ) );
00104     ConstCheck( 0, test_construct_iter_range<TestList>( testList2 ) );
00105     ConstCheck( testList, test_copy_construct<TestList>() );
00106 
00107     WeakCheck( testList, test_assign_op<TestList>( testList2 ) );
00108 }

Generated on Sun May 27 2012 04:35:15 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.