aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaz Wesley <keziahw@gmail.com>2016-04-16 06:49:38 -0700
committerKaz Wesley <keziahw@gmail.com>2016-04-16 08:05:11 -0700
commit4ed41a2b611dfd328fe6f72312d6c596650f03f8 (patch)
tree392a381898d4975e90da2689bd707d9889ed9593
parent1e2c29f2632c378843c5a3c9ad401a7bcacc4de0 (diff)
downloadbitcoin-4ed41a2b611dfd328fe6f72312d6c596650f03f8.tar.xz
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
-rw-r--r--src/test/prevector_tests.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp
index 01a45b540d..b39b903530 100644
--- a/src/test/prevector_tests.cpp
+++ b/src/test/prevector_tests.cpp
@@ -19,9 +19,11 @@ template<unsigned int N, typename T>
class prevector_tester {
typedef std::vector<T> realtype;
realtype real_vector;
+ realtype real_vector_alt;
typedef prevector<N, T> pretype;
pretype pre_vector;
+ pretype pre_vector_alt;
typedef typename pretype::size_type Size;
@@ -149,6 +151,12 @@ public:
pre_vector.shrink_to_fit();
test();
}
+
+ void swap() {
+ real_vector.swap(real_vector_alt);
+ pre_vector.swap(pre_vector_alt);
+ test();
+ }
};
BOOST_AUTO_TEST_CASE(PrevectorTestInt)
@@ -204,12 +212,15 @@ BOOST_AUTO_TEST_CASE(PrevectorTestInt)
if (test.size() > 0) {
test.update(insecure_rand() % test.size(), insecure_rand());
}
- if (((r >> 11) & 1024) == 11) {
+ if (((r >> 11) % 1024) == 11) {
test.clear();
}
- if (((r >> 21) & 512) == 12) {
+ if (((r >> 21) % 512) == 12) {
test.assign(insecure_rand() % 32, insecure_rand());
}
+ if (((r >> 15) % 64) == 3) {
+ test.swap();
+ }
}
}
}