Skip to content

Commit 4ed41a2

Browse files
committed
test prevector::swap
- add a swap operation to prevector tests (fails due to broken prevector::swap) - fix 2 prevector test operation conditions that were impossible
1 parent 1e2c29f commit 4ed41a2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/test/prevector_tests.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ template<unsigned int N, typename T>
1919
class prevector_tester {
2020
typedef std::vector<T> realtype;
2121
realtype real_vector;
22+
realtype real_vector_alt;
2223

2324
typedef prevector<N, T> pretype;
2425
pretype pre_vector;
26+
pretype pre_vector_alt;
2527

2628
typedef typename pretype::size_type Size;
2729

@@ -149,6 +151,12 @@ class prevector_tester {
149151
pre_vector.shrink_to_fit();
150152
test();
151153
}
154+
155+
void swap() {
156+
real_vector.swap(real_vector_alt);
157+
pre_vector.swap(pre_vector_alt);
158+
test();
159+
}
152160
};
153161

154162
BOOST_AUTO_TEST_CASE(PrevectorTestInt)
@@ -204,12 +212,15 @@ BOOST_AUTO_TEST_CASE(PrevectorTestInt)
204212
if (test.size() > 0) {
205213
test.update(insecure_rand() % test.size(), insecure_rand());
206214
}
207-
if (((r >> 11) & 1024) == 11) {
215+
if (((r >> 11) % 1024) == 11) {
208216
test.clear();
209217
}
210-
if (((r >> 21) & 512) == 12) {
218+
if (((r >> 21) % 512) == 12) {
211219
test.assign(insecure_rand() % 32, insecure_rand());
212220
}
221+
if (((r >> 15) % 64) == 3) {
222+
test.swap();
223+
}
213224
}
214225
}
215226
}

0 commit comments

Comments
 (0)