66 |
66 |
67 EFFECTS: Performs tests on bit vectors |
67 EFFECTS: Performs tests on bit vectors |
68 ====================================================================================*/ |
68 ====================================================================================*/ |
69 void test_bit_vector() |
69 void test_bit_vector() |
70 { |
70 { |
71 #define __WORD_BIT (int(CHAR_BIT*sizeof(unsigned int))) |
71 #define __WORD_BIT_LOCAL (int(CHAR_BIT*sizeof(unsigned int))) |
72 |
72 |
73 // Make some bit vectors to work with. |
73 // Make some bit vectors to work with. |
74 BitVector emptyVector; |
74 BitVector emptyVector; |
75 BitVector testVector, testVector2; |
75 BitVector testVector, testVector2; |
76 |
76 |
77 EH_ASSERT( testVector.size() == 0 ); |
77 EH_ASSERT( testVector.size() == 0 ); |
78 |
78 |
79 size_t BitVectorSize = random_number( random_base ); |
79 size_t BitVectorSize = random_number( random_base ); |
80 // Half the time, choose a size that will guarantee immediate reallocation |
80 // Half the time, choose a size that will guarantee immediate reallocation |
81 if ( random_number(2) ) |
81 if ( random_number(2) ) |
82 BitVectorSize = BitVectorSize / __WORD_BIT * __WORD_BIT; |
82 BitVectorSize = BitVectorSize / __WORD_BIT_LOCAL * __WORD_BIT_LOCAL; |
83 |
83 |
84 EH_ASSERT( testVector.size() == 0 ); |
84 EH_ASSERT( testVector.size() == 0 ); |
85 testVector.reserve(BitVectorSize); |
85 testVector.reserve(BitVectorSize); |
86 EH_ASSERT( testVector.size() == 0 ); |
86 EH_ASSERT( testVector.size() == 0 ); |
87 while (testVector.size() < BitVectorSize) { |
87 while (testVector.size() < BitVectorSize) { |