From 09f8d4a4b20f234dafcdf2ce667f220801b9210f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 19 Aug 2018 01:42:30 +0200 Subject: Make size of bit vectors precise --- test/test_bitvec.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/test_bitvec.cpp b/test/test_bitvec.cpp index 2fa62ca..178b39a 100644 --- a/test/test_bitvec.cpp +++ b/test/test_bitvec.cpp @@ -200,13 +200,13 @@ void test_left_rotate(Context& ctx) { const T v = make_random_bitvec(ctx); - for (size_t width = 0; width < std::min(N, size_t(128)); ++width) { - for (size_t bits = 0; bits <= width; ++bits) { - T r = v; - r.rotl(bits, width); + for (size_t bits = 0; bits <= N; ++bits) { + T r = v; + r.rotl(bits); - for (size_t i = 0; i < width; ++i) { - assert(r.test((i + bits) % width) == v.test(i)); + if (N > 0) { + for (size_t i = 0; i < N; ++i) { + assert(r.test((i + bits) % N) == v.test(i)); } } } @@ -217,13 +217,13 @@ void test_right_rotate(Context& ctx) { const T v = make_random_bitvec(ctx); - for (size_t width = 0; width < std::min(N, size_t(128)); ++width) { - for (size_t bits = 0; bits <= width; ++bits) { - T r = v; - r.rotr(bits, width); + for (size_t bits = 0; bits <= N; ++bits) { + T r = v; + r.rotr(bits); - for (size_t i = 0; i < width; ++i) { - assert(r.test(i) == v.test((i + bits) % width)); + if (N > 0) { + for (size_t i = 0; i < N; ++i) { + assert(r.test(i) == v.test((i + bits) % N)); } } } -- cgit v1.2.1