ReactOS 0.4.16-dev-297-gc569aee
test_list.cpp
Go to the documentation of this file.
1/***********************************************************************************
2 test_list.cpp
3
4 * Copyright (c) 1997
5 * Mark of the Unicorn, Inc.
6 *
7 * Permission to use, copy, modify, distribute and sell this software
8 * and its documentation for any purpose is hereby granted without fee,
9 * provided that the above copyright notice appear in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation. Mark of the Unicorn makes no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
14
15***********************************************************************************/
16#include "Tests.h"
17#include "TestClass.h"
18#include "LeakCheck.h"
19# if defined (EH_NEW_HEADERS)
20#include <list>
21#else
22#include <list.h>
23#endif
24#include "test_construct.h"
25#include "test_assign_op.h"
26#include "test_push_back.h"
27#include "test_insert.h"
28#include "test_push_front.h"
29#include "nc_alloc.h"
30
31typedef EH_STD::__list__<TestClass, eh_allocator(TestClass) > TestList;
32
35{
37}
38
39//
40// list sort() member test operation. Does not verify stability.
41//
43{
45 {
46 gTestController.SetCurrentTestName("list::sort()");
47 }
48
49 void operator()( TestList& list ) const
50 {
51 list.sort();
52
54
55 for ( TestList::iterator p = list.begin(); p != list.end(); p++ )
56 if ( p != list.begin() ) {
57 TestList::iterator tmp=p;
58 --tmp;
59 EH_ASSERT( *p >= *tmp );
60 }
61 }
62};
63
65{
66 TestList testList, testList2;
67 size_t listSize = random_number(random_base);
68
69 while ( testList.size() < listSize )
70 {
72 testList.push_back( x );
73 testList2.push_back( TestClass() );
74 }
75
76 StrongCheck( testList, test_insert_one<TestList>(testList) );
77 StrongCheck( testList, test_insert_one<TestList>(testList, 0) );
78 StrongCheck( testList, test_insert_one<TestList>(testList, (int)testList.size()) );
79
82 WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base), (int)testList.size() ) );
83
84 size_t insCnt = random_number(random_base);
85 TestClass *insFirst = new TestList::value_type[1+insCnt];
86
87 WeakCheck( testList, insert_range_tester(testList, insFirst, insFirst+insCnt) );
88 WeakCheck( testList, insert_range_at_begin_tester(testList, insFirst, insFirst+insCnt) );
89 WeakCheck( testList, insert_range_at_end_tester(testList, insFirst, insFirst+insCnt) );
90
91 ConstCheck( 0, test_construct_pointer_range<TestList>(insFirst, insFirst+insCnt) );
92 delete[] insFirst;
93
94 WeakCheck( testList, insert_range_tester(testList, testList2.begin(), testList2.end() ) );
95
96 StrongCheck( testList, test_push_front<TestList>(testList) );
97 StrongCheck( testList, test_push_back<TestList>(testList) );
98
99 StrongCheck( testList, test_list_sort() ); // Simply to verify strength.
100
106
107 WeakCheck( testList, test_assign_op<TestList>( testList2 ) );
108}
void ConstCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:103
void StrongCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:145
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
#define eh_allocator(T)
Definition: Prefix.h:174
#define EH_ASSERT
Definition: Prefix.h:37
Definition: list.h:37
void sort()
Definition: _list.h:660
iterator begin()
Definition: _list.h:367
iterator end()
Definition: _list.h:370
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLfloat GLfloat p
Definition: glext.h:8902
TestController gTestController
Definition: nc_alloc.cpp:46
unsigned random_number(size_t range)
unsigned random_base
static void SetCurrentTestName(const char *str)
Definition: nc_alloc.h:172
static void CancelFailureCountdown()
Definition: nc_alloc.h:143
void operator()(TestList &list) const
Definition: test_list.cpp:49
test_insert_range< C, Iter > insert_range_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:535
test_insert_range< C, Iter > insert_range_at_begin_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:541
test_insert_range< C, Iter > insert_range_at_end_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:547
EH_STD::__list__< TestClass, eh_allocator(TestClass) > TestList
Definition: test_list.cpp:31
void test_list()
Definition: test_list.cpp:64
sequence_container_tag container_category(const TestList &)
Definition: test_list.cpp:34