ReactOS  0.4.15-dev-1039-gb9754fa
test_bit_vector.cpp File Reference
#include "Tests.h"
#include <vector>
#include "LeakCheck.h"
#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_bit_vector.cpp:

Go to the source code of this file.

Classes

struct  test_BitVector_reserve
 

Macros

#define __WORD_BIT   (int(CHAR_BIT*sizeof(unsigned int)))
 

Typedefs

typedef EH_BIT_VECTOR BitVector
 

Functions

sequence_container_tag container_category (const BitVector &)
 
void test_bit_vector ()
 

Macro Definition Documentation

◆ __WORD_BIT

#define __WORD_BIT   (int(CHAR_BIT*sizeof(unsigned int)))

Typedef Documentation

◆ BitVector

Definition at line 36 of file test_bit_vector.cpp.

Function Documentation

◆ container_category()

sequence_container_tag container_category ( const BitVector )
inline

◆ test_bit_vector()

void test_bit_vector ( )

Definition at line 69 of file test_bit_vector.cpp.

70 {
71 #define __WORD_BIT (int(CHAR_BIT*sizeof(unsigned int)))
72 
73  // Make some bit vectors to work with.
74  BitVector emptyVector;
75  BitVector testVector, testVector2;
76 
77  EH_ASSERT( testVector.size() == 0 );
78 
79  size_t BitVectorSize = random_number( random_base );
80  // Half the time, choose a size that will guarantee immediate reallocation
81  if ( random_number(2) )
82  BitVectorSize = BitVectorSize / __WORD_BIT * __WORD_BIT;
83 
84  EH_ASSERT( testVector.size() == 0 );
85  testVector.reserve(BitVectorSize);
86  EH_ASSERT( testVector.size() == 0 );
87  while (testVector.size() < BitVectorSize) {
88  testVector.push_back(random_number(2) != 0);
89  testVector2.push_back(random_number(2) != 0);
90  }
91 
92  // Test insertions
93  StrongCheck(testVector, test_insert_one<BitVector>(testVector) );
94  StrongCheck(testVector, test_insert_one<BitVector>(testVector,0) );
95  StrongCheck(testVector, test_insert_one<BitVector>(testVector, (int)testVector.size()) );
96 
98  StrongCheck(testVector, test_insert_n<BitVector>(testVector, random_number(random_base),0 ) );
99  StrongCheck(testVector, test_insert_n<BitVector>(testVector, random_number(random_base), (int)testVector.size()) );
100 #if 0
101  // Allocate some random bools to insert
102  size_t insCnt = 1 + random_number(random_base);
103  bool *insFirst = new BitVector::value_type[insCnt];
104  for (size_t n = 0; n < insCnt; n++)
105  insFirst[n] = random_number(2);
106  StrongCheck(testVector, insert_range_tester(testVector, insFirst, insFirst+insCnt));
107  StrongCheck(testVector, insert_range_at_begin_tester(testVector, insFirst, insFirst+insCnt));
108  StrongCheck(testVector, insert_range_at_end_tester(testVector, insFirst, insFirst+insCnt));
109  ConstCheck(0, test_construct_pointer_range<BitVector>( insFirst, insFirst + insCnt));
110  delete[] insFirst;
111 #endif
112  StrongCheck(testVector, insert_range_tester(testVector, testVector2.begin(), testVector2.end()));
113  StrongCheck(testVector, insert_range_at_begin_tester(testVector, testVector2.begin(),
114  testVector2.end()));
115  StrongCheck(testVector, insert_range_at_end_tester(testVector, testVector2.begin(),
116  testVector2.end()));
117  StrongCheck(testVector, test_BitVector_reserve( testVector.capacity() + random_number(50)));
118  StrongCheck(testVector, test_push_back<BitVector>(testVector));
119  StrongCheck(emptyVector, test_push_back<BitVector>(emptyVector));
120 
126  WeakCheck(testVector, test_assign_op<BitVector>(testVector2) );
127 }
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
GLdouble n
Definition: glext.h:7729
EH_BIT_VECTOR BitVector
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
#define EH_ASSERT
Definition: Prefix.h:37
unsigned random_number(size_t range)
void StrongCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:145
#define __WORD_BIT

Referenced by main().