| 958 | } |
| 959 | |
| 960 | static void TestZigZag64(int64_t v, std::array<uint8_t, 10> buffer_expect) { |
| 961 | uint8_t buffer[bit_util::kMaxLEB128ByteLenFor<int64_t>] = {}; |
| 962 | bit_util::BitWriter writer(buffer, sizeof(buffer)); |
| 963 | writer.PutZigZagVlqInt(v); |
| 964 | // WARNING: The reader reads and caches the input when created, so it must be created |
| 965 | // after the data is written in the buffer. |
| 966 | bit_util::BitReader reader(buffer, sizeof(buffer)); |
| 967 | EXPECT_THAT(buffer, testing::ElementsAreArray(buffer_expect)); |
| 968 | int64_t result = 0; |
| 969 | EXPECT_TRUE(reader.GetZigZagVlqInt(&result)); |
| 970 | EXPECT_EQ(v, result); |
| 971 | } |
| 972 | |
| 973 | TEST(BitStreamUtil, ZigZag64) { |
| 974 | TestZigZag64(0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); |
no test coverage detected