From 6929b08616613fb87638c2ffa2682ef5d8fd54dd Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 19 Aug 2014 09:52:54 -0400 Subject: [PATCH] Remove BitStream* tests --- util/coding_test.cc | 93 --------------------------------------------- 1 file changed, 93 deletions(-) diff --git a/util/coding_test.cc b/util/coding_test.cc index ed542d6bf..3dbe7befe 100644 --- a/util/coding_test.cc +++ b/util/coding_test.cc @@ -196,99 +196,6 @@ TEST(Coding, Strings) { ASSERT_EQ("", input.ToString()); } -TEST(Coding, BitStream) { - const int kNumBytes = 10; - char bytes[kNumBytes+1]; - for (int i = 0; i < kNumBytes + 1; ++i) { - bytes[i] = '\0'; - } - - // Simple byte aligned test. - for (int i = 0; i < kNumBytes; ++i) { - BitStreamPutInt(bytes, kNumBytes, i*8, 8, 255-i); - - ASSERT_EQ((unsigned char)bytes[i], (unsigned char)(255-i)); - } - for (int i = 0; i < kNumBytes; ++i) { - ASSERT_EQ(BitStreamGetInt(bytes, kNumBytes, i*8, 8), (uint32_t)(255-i)); - } - ASSERT_EQ(bytes[kNumBytes], '\0'); - - // Write and read back at strange offsets - for (int i = 0; i < kNumBytes + 1; ++i) { - bytes[i] = '\0'; - } - for (int i = 0; i < kNumBytes; ++i) { - BitStreamPutInt(bytes, kNumBytes, i*5+1, 4, (i * 7) % (1 << 4)); - } - for (int i = 0; i < kNumBytes; ++i) { - ASSERT_EQ(BitStreamGetInt(bytes, kNumBytes, i*5+1, 4), - (uint32_t)((i * 7) % (1 << 4))); - } - ASSERT_EQ(bytes[kNumBytes], '\0'); - - // Create 11011011 as a bit pattern - for (int i = 0; i < kNumBytes + 1; ++i) { - bytes[i] = '\0'; - } - for (int i = 0; i < kNumBytes; ++i) { - BitStreamPutInt(bytes, kNumBytes, i*8, 2, 3); - BitStreamPutInt(bytes, kNumBytes, i*8+3, 2, 3); - BitStreamPutInt(bytes, kNumBytes, i*8+6, 2, 3); - - ASSERT_EQ((unsigned char)bytes[i], - (unsigned char)(3 + (3 << 3) + (3 << 6))); - } - ASSERT_EQ(bytes[kNumBytes], '\0'); - - - // Test large values - for (int i = 0; i < kNumBytes + 1; ++i) { - bytes[i] = '\0'; - } - BitStreamPutInt(bytes, kNumBytes, 0, 64, (uint64_t)(-1)); - for (int i = 0; i < 64/8; ++i) { - ASSERT_EQ((unsigned char)bytes[i], - (unsigned char)(255)); - } - ASSERT_EQ(bytes[64/8], '\0'); - - -} - -TEST(Coding, BitStreamConvenienceFuncs) { - std::string bytes(1, '\0'); - - // Check that independent changes to byte are preserved. - BitStreamPutInt(&bytes, 0, 2, 3); - BitStreamPutInt(&bytes, 3, 2, 3); - BitStreamPutInt(&bytes, 6, 2, 3); - ASSERT_EQ((unsigned char)bytes[0], (unsigned char)(3 + (3 << 3) + (3 << 6))); - ASSERT_EQ(BitStreamGetInt(&bytes, 0, 2), 3u); - ASSERT_EQ(BitStreamGetInt(&bytes, 3, 2), 3u); - ASSERT_EQ(BitStreamGetInt(&bytes, 6, 2), 3u); - Slice slice(bytes); - ASSERT_EQ(BitStreamGetInt(&slice, 0, 2), 3u); - ASSERT_EQ(BitStreamGetInt(&slice, 3, 2), 3u); - ASSERT_EQ(BitStreamGetInt(&slice, 6, 2), 3u); - - // Test overlapping crossing over byte boundaries - bytes = std::string(2, '\0'); - BitStreamPutInt(&bytes, 6, 4, 15); - ASSERT_EQ((unsigned char)bytes[0], 3 << 6); - ASSERT_EQ((unsigned char)bytes[1], 3); - ASSERT_EQ(BitStreamGetInt(&bytes, 6, 4), 15u); - slice = Slice(bytes); - ASSERT_EQ(BitStreamGetInt(&slice, 6, 4), 15u); - - // Test 64-bit number - bytes = std::string(64/8, '\0'); - BitStreamPutInt(&bytes, 0, 64, (uint64_t)(-1)); - ASSERT_EQ(BitStreamGetInt(&bytes, 0, 64), (uint64_t)(-1)); - slice = Slice(bytes); - ASSERT_EQ(BitStreamGetInt(&slice, 0, 64), (uint64_t)(-1)); -} - } // namespace rocksdb int main(int argc, char** argv) {