ReactOS  0.4.15-dev-1039-gb9754fa
test_vector.cpp File Reference
#include "Tests.h"
#include "TestClass.h"
#include "LeakCheck.h"
#include <vector>
#include "test_construct.h"
#include "test_assign_op.h"
#include "test_push_back.h"
#include "test_insert.h"
#include "test_push_front.h"
Include dependency graph for test_vector.cpp:

Go to the source code of this file.

Classes

struct  test_reserve
 

Typedefs

typedef EH_STD::__vector__< TestClass, eh_allocator(TestClass) > TestVector
 

Functions

sequence_container_tag container_category (const TestVector &)
 
void prepare_insert_n (TestVector &c, size_t insCnt)
 
void prepare_insert_range (TestVector &vec, size_t, TestClass *first, TestClass *last)
 
void test_vector ()
 

Typedef Documentation

◆ TestVector

Function Documentation

◆ container_category()

sequence_container_tag container_category ( const TestVector )
inline

Definition at line 37 of file test_vector.cpp.

38 {
39  return sequence_container_tag();
40 }

◆ prepare_insert_n()

void prepare_insert_n ( TestVector c,
size_t  insCnt 
)

Definition at line 44 of file test_vector.cpp.

45 {
46  if ( random_number(2) )
47  c.reserve( c.size() + insCnt );
48 }
const GLubyte * c
Definition: glext.h:8905
unsigned random_number(size_t range)

◆ prepare_insert_range()

void prepare_insert_range ( TestVector vec,
size_t  ,
TestClass first,
TestClass last 
)
inline

Definition at line 64 of file test_vector.cpp.

65 {
66  if ( random_number(2) )
67  {
68  ptrdiff_t d = 0;
69  EH_DISTANCE( first, last, d );
70  vec.reserve( vec.size() + d );
71  }
72 }
POINT last
Definition: font.c:46
const GLint * first
Definition: glext.h:5794
#define EH_DISTANCE(a, b, result)
Definition: Prefix.h:98
#define d
Definition: ke_i.h:81
FT_Vector * vec
Definition: ftbbox.c:448
unsigned random_number(size_t range)
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247

◆ test_vector()

void test_vector ( )

Definition at line 74 of file test_vector.cpp.

75 {
76 
78 
79  TestVector emptyVector;
80  TestVector testVector, testVector2;
81  size_t vectorSize = random_number(random_base);
82 
83  testVector.reserve(vectorSize*4);
84  while ( testVector.size() < vectorSize )
85  {
86  TestClass x;
87  testVector.push_back( x );
88  testVector2.push_back( TestClass() );
89  }
90 
91  size_t insCnt = random_number(random_base);
92  TestClass *insFirst = new TestVector::value_type[1+ insCnt];
93 
94  ConstCheck( 0, test_construct_pointer_range<TestVector>(insFirst, insFirst+insCnt) );
95 
96  WeakCheck( testVector, insert_range_tester(testVector, insFirst, insFirst+insCnt) );
97  WeakCheck( testVector, insert_range_at_begin_tester(testVector, insFirst, insFirst+insCnt) );
98  WeakCheck( testVector, insert_range_at_end_tester(testVector, insFirst, insFirst+insCnt) );
99  delete[] insFirst;
100 
101  WeakCheck( testVector, test_insert_one<TestVector>(testVector) );
102  WeakCheck( testVector, test_insert_one<TestVector>(testVector, 0) );
103  WeakCheck( testVector, test_insert_one<TestVector>(testVector, (int)testVector.size()) );
104 
105  WeakCheck( testVector, test_insert_n<TestVector>(testVector, random_number(random_base) ) );
106  WeakCheck( testVector, test_insert_n<TestVector>(testVector, random_number(random_base), 0 ) );
107  WeakCheck( testVector, test_insert_n<TestVector>(testVector, random_number(random_base), (int)testVector.size() ) );
108 
109  WeakCheck( testVector, insert_range_tester(testVector, testVector2.begin(), testVector2.end() ) );
110 
111 
112  StrongCheck( testVector, test_reserve( testVector.capacity() + random_number(random_base) ) );
113  StrongCheck( testVector, test_push_back<TestVector>(testVector) );
114  StrongCheck( emptyVector, test_push_back<TestVector>(emptyVector) );
115 
120 
121  testVector2.resize( testVector.size() * 3 / 2 );
122  WeakCheck( testVector, test_assign_op<TestVector>( testVector2 ) );
123  testVector2.clear();
124  testVector2.resize( testVector.size() * 2 / 3 );
125  WeakCheck( testVector, test_assign_op<TestVector>( testVector2 ) );
126 }
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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_end_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:547
void ConstCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:103
unsigned random_base
test_insert_range< C, Iter > insert_range_at_begin_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:541
unsigned random_number(size_t range)
EH_STD::__vector__< TestClass, eh_allocator(TestClass) > TestVector
Definition: test_vector.cpp:33
void StrongCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:145

Referenced by main().