| 934 | } |
| 935 | |
| 936 | static void TestZigZag(int32_t v, std::array<uint8_t, 5> buffer_expect) { |
| 937 | uint8_t buffer[bit_util::kMaxLEB128ByteLenFor<int32_t>] = {}; |
| 938 | bit_util::BitWriter writer(buffer, sizeof(buffer)); |
| 939 | writer.PutZigZagVlqInt(v); |
| 940 | // WARNING: The reader reads and caches the input when created, so it must be created |
| 941 | // after the data is written in the buffer. |
| 942 | bit_util::BitReader reader(buffer, sizeof(buffer)); |
| 943 | EXPECT_THAT(buffer, testing::ElementsAreArray(buffer_expect)); |
| 944 | int32_t result; |
| 945 | EXPECT_TRUE(reader.GetZigZagVlqInt(&result)); |
| 946 | EXPECT_EQ(v, result); |
| 947 | } |
| 948 | |
| 949 | TEST(BitStreamUtil, ZigZag) { |
| 950 | TestZigZag(0, {0, 0, 0, 0, 0}); |
no test coverage detected