ReactOS 0.4.15-dev-5666-gc548b97
test_deque.cpp
Go to the documentation of this file.
1/***********************************************************************************
2 test_deque.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
17#include "Tests.h"
18# if defined (EH_NEW_HEADERS)
19# ifdef __SUNPRO_CC
20# include <stdio.h>
21# else
22# include <cstdio>
23# endif
24# include <deque>
25# else
26# include <stdio.h>
27# include <deque.h>
28# endif
29#include "TestClass.h"
30#include "LeakCheck.h"
31#include "test_construct.h"
32#include "test_assign_op.h"
33#include "test_push_back.h"
34#include "test_insert.h"
35#include "test_push_front.h"
36
38
40
43{
45}
46
48{
49 size_t dequeSize = random_number(random_base);
50 TestDeque emptyDeque;
51 TestDeque testDeque, testDeque2;
52 while ( testDeque.size() < dequeSize )
53 {
55 testDeque.push_back( x );
56 testDeque2.push_back( DQTestClass() );
57 }
58
60 WeakCheck( testDeque, test_insert_one<TestDeque>(testDeque) );
61 StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque, 0) );
62 StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque, (int)testDeque.size()) );
63
66 StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), (int)testDeque.size() ) );
67
68 size_t insCnt = random_number(random_base);
69 DQTestClass *insFirst = new TestDeque::value_type[insCnt + 1];
70
71 WeakCheck( testDeque, insert_range_tester(testDeque, insFirst, insFirst + insCnt) );
72 StrongCheck( testDeque, insert_range_at_begin_tester(testDeque, insFirst, insFirst + insCnt) );
73 StrongCheck( testDeque, insert_range_at_end_tester(testDeque, insFirst, insFirst + insCnt) );
74
75 ConstCheck( 0, test_construct_pointer_range<TestDeque>(insFirst, insFirst + insCnt) );
76 delete[] insFirst;
77
78 WeakCheck( testDeque, insert_range_tester(testDeque, testDeque2.begin(), testDeque2.end() ) );
79
80 StrongCheck( testDeque, test_push_back<TestDeque>(testDeque) );
81 StrongCheck( emptyDeque, test_push_back<TestDeque>(emptyDeque) );
82 StrongCheck( testDeque, test_push_front<TestDeque>(testDeque) );
83 StrongCheck( emptyDeque, test_push_front<TestDeque>(emptyDeque) );
84
85
90
91 testDeque2.resize( testDeque.size() * 3 / 2 );
92 WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) );
93 testDeque2.resize( testDeque.size() * 2 / 3 );
94 WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) );
95}
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
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned random_number(size_t range)
unsigned random_base
TestClass DQTestClass
Definition: test_deque.cpp:37
sequence_container_tag container_category(const TestDeque &)
Definition: test_deque.cpp:42
void test_deque()
Definition: test_deque.cpp:47
EH_STD::deque< DQTestClass, eh_allocator(DQTestClass) > TestDeque
Definition: test_deque.cpp:39
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