summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/bits
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-04 00:00:14 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-04 00:00:14 +0000
commit70327112cb2679dcf0e4879d71fe745c33a42bb7 (patch)
treebcd43231e89be2a71eab3810a29463702378d91b /vespalib/src/tests/bits
parent730d3e0d462fcc69aaa47c30f1ed868471ce10ad (diff)
Drop boost crc, random and tokenizer
Diffstat (limited to 'vespalib/src/tests/bits')
-rw-r--r--vespalib/src/tests/bits/bits_test.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/vespalib/src/tests/bits/bits_test.cpp b/vespalib/src/tests/bits/bits_test.cpp
index 47d691c739d..7d4de014860 100644
--- a/vespalib/src/tests/bits/bits_test.cpp
+++ b/vespalib/src/tests/bits/bits_test.cpp
@@ -2,14 +2,6 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/bits.h>
-#include <boost/crc.hpp>
-#include <boost/version.hpp>
-
-#if BOOST_VERSION < 106900
- #define REFLECT reflect
-#else
- #define REFLECT reflect_q
-#endif
using namespace vespalib;
@@ -18,7 +10,7 @@ class Test : public TestApp
public:
int Main() override;
template <typename T>
- void testFixed(const T * v, size_t sz);
+ void testFixed(const T * v, size_t sz, const T * exp);
void testBuffer();
};
@@ -26,26 +18,30 @@ int
Test::Main()
{
TEST_INIT("bits_test");
- uint8_t u8[5] = { 0, 1, 127, 135, 255 };
- testFixed(u8, sizeof(u8)/sizeof(u8[0]));
- uint16_t u16[5] = { 0, 1, 127, 135, 255 };
- testFixed(u16, sizeof(u16)/sizeof(u16[0]));
- uint32_t u32[5] = { 0, 1, 127, 135, 255 };
- testFixed(u32, sizeof(u32)/sizeof(u32[0]));
- uint64_t u64[5] = { 0, 1, 127, 135, 255 };
- testFixed(u64, sizeof(u64)/sizeof(u64[0]));
+ uint8_t u8[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint8_t exp8[5] = { 0, 0x80, 0xfe, 0xe1, 0xff };
+ testFixed(u8, sizeof(u8)/sizeof(u8[0]), exp8);
+ uint16_t u16[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint16_t exp16[5] = { 0, 0x8000, 0xfe00, 0xe100, 0xff00 };
+ testFixed(u16, sizeof(u16)/sizeof(u16[0]), exp16);
+ uint32_t u32[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint32_t exp32[5] = { 0, 0x80000000, 0xfe000000, 0xe1000000, 0xff000000 };
+ testFixed(u32, sizeof(u32)/sizeof(u32[0]), exp32);
+ uint64_t u64[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint64_t exp64[5] = { 0, 0x8000000000000000, 0xfe00000000000000, 0xe100000000000000, 0xff00000000000000 };
+ testFixed(u64, sizeof(u64)/sizeof(u64[0]), exp64);
testBuffer();
TEST_DONE();
}
template <typename T>
-void Test::testFixed(const T * v, size_t sz)
+void Test::testFixed(const T * v, size_t sz, const T * exp)
{
EXPECT_EQUAL(0u, Bits::reverse(static_cast<T>(0)));
EXPECT_EQUAL(1ul << (sizeof(T)*8 - 1), Bits::reverse(static_cast<T>(1)));
EXPECT_EQUAL(static_cast<T>(-1), Bits::reverse(static_cast<T>(-1)));
for (size_t i(0); i < sz; i++) {
- EXPECT_EQUAL(Bits::reverse(v[i]), boost::detail::reflector<sizeof(T)*8>::REFLECT(v[i]));
+ EXPECT_EQUAL(Bits::reverse(v[i]), exp[i]);
EXPECT_EQUAL(Bits::reverse(Bits::reverse(v[i])), v[i]);
}
}