Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 1 | // Copyright 2019 The Pigweed Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
Wyatt Hepler | 8c493bb | 2019-12-02 14:49:21 -0800 | [diff] [blame] | 4 | // use this file except in compliance with the License. You may obtain a copy of |
| 5 | // the License at |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
Wyatt Hepler | 8c493bb | 2019-12-02 14:49:21 -0800 | [diff] [blame] | 12 | // License for the specific language governing permissions and limitations under |
| 13 | // the License. |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 14 | |
| 15 | #include "pw_varint/varint.h" |
| 16 | |
| 17 | #include <cinttypes> |
| 18 | #include <cstdint> |
| 19 | #include <cstring> |
| 20 | #include <limits> |
| 21 | |
| 22 | #include "gtest/gtest.h" |
| 23 | |
| 24 | namespace pw::varint { |
| 25 | namespace { |
| 26 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 27 | extern "C" { |
| 28 | |
| 29 | // Functions defined in varint_test.c which call the varint API from C. |
| 30 | size_t pw_VarintCallEncode(uint64_t integer, void* output, size_t output_size); |
| 31 | size_t pw_VarintCallZigZagEncode(int64_t integer, |
| 32 | void* output, |
| 33 | size_t output_size); |
| 34 | size_t pw_VarintCallDecode(void* input, size_t input_size, uint64_t* output); |
| 35 | size_t pw_VarintCallZigZagDecode(void* input, |
| 36 | size_t input_size, |
| 37 | int64_t* output); |
| 38 | |
| 39 | } // extern "C" |
| 40 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 41 | class Varint : public ::testing::Test { |
| 42 | protected: |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 43 | Varint() |
| 44 | : buffer_{std::byte{'a'}, |
| 45 | std::byte{'b'}, |
| 46 | std::byte{'c'}, |
| 47 | std::byte{'d'}, |
| 48 | std::byte{'e'}, |
| 49 | std::byte{'f'}, |
| 50 | std::byte{'g'}, |
| 51 | std::byte{'h'}, |
| 52 | std::byte{'i'}, |
| 53 | std::byte{'j'}} {} |
| 54 | std::byte buffer_[10]; |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | TEST_F(Varint, EncodeSizeUnsigned32_SmallSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 58 | ASSERT_EQ(1u, Encode(UINT32_C(0), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 59 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 60 | ASSERT_EQ(1u, Encode(UINT32_C(1), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 61 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 62 | ASSERT_EQ(1u, Encode(UINT32_C(2), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 63 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 64 | } |
| 65 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 66 | TEST_F(Varint, EncodeSizeUnsigned32_SmallSingleByte_C) { |
| 67 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(0), buffer_, sizeof(buffer_))); |
| 68 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
| 69 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(1), buffer_, sizeof(buffer_))); |
| 70 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
| 71 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(2), buffer_, sizeof(buffer_))); |
| 72 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
| 73 | } |
| 74 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 75 | TEST_F(Varint, EncodeSizeUnsigned32_LargeSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 76 | ASSERT_EQ(1u, Encode(UINT32_C(63), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 77 | EXPECT_EQ(std::byte{63}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 78 | ASSERT_EQ(1u, Encode(UINT32_C(64), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 79 | EXPECT_EQ(std::byte{64}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 80 | ASSERT_EQ(1u, Encode(UINT32_C(126), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 81 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 82 | ASSERT_EQ(1u, Encode(UINT32_C(127), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 83 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 86 | TEST_F(Varint, EncodeSizeUnsigned32_LargeSingleByte_C) { |
| 87 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(63), buffer_, sizeof(buffer_))); |
| 88 | EXPECT_EQ(std::byte{63}, buffer_[0]); |
| 89 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(64), buffer_, sizeof(buffer_))); |
| 90 | EXPECT_EQ(std::byte{64}, buffer_[0]); |
| 91 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(126), buffer_, sizeof(buffer_))); |
| 92 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
| 93 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT32_C(127), buffer_, sizeof(buffer_))); |
| 94 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
| 95 | } |
| 96 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 97 | TEST_F(Varint, EncodeSizeUnsigned32_MultiByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 98 | ASSERT_EQ(2u, Encode(UINT32_C(128), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 99 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 100 | ASSERT_EQ(2u, Encode(UINT32_C(129), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 101 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
| 102 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 103 | ASSERT_EQ(5u, Encode(std::numeric_limits<uint32_t>::max() - 1, buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 104 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 105 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 106 | ASSERT_EQ(5u, Encode(std::numeric_limits<uint32_t>::max(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 107 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 108 | } |
| 109 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 110 | TEST_F(Varint, EncodeSizeUnsigned32_MultiByte_C) { |
| 111 | ASSERT_EQ(2u, pw_VarintCallEncode(UINT32_C(128), buffer_, sizeof(buffer_))); |
| 112 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
| 113 | ASSERT_EQ(2u, pw_VarintCallEncode(UINT32_C(129), buffer_, sizeof(buffer_))); |
| 114 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
| 115 | |
| 116 | ASSERT_EQ( |
| 117 | 5u, |
| 118 | pw_VarintCallEncode( |
| 119 | std::numeric_limits<uint32_t>::max() - 1, buffer_, sizeof(buffer_))); |
| 120 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 121 | |
| 122 | ASSERT_EQ( |
| 123 | 5u, |
| 124 | pw_VarintCallEncode( |
| 125 | std::numeric_limits<uint32_t>::max(), buffer_, sizeof(buffer_))); |
| 126 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 127 | } |
| 128 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 129 | TEST_F(Varint, EncodeSizeSigned32_SmallSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 130 | ASSERT_EQ(1u, Encode(INT32_C(0), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 131 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 132 | ASSERT_EQ(1u, Encode(INT32_C(-1), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 133 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 134 | ASSERT_EQ(1u, Encode(INT32_C(1), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 135 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 136 | ASSERT_EQ(1u, Encode(INT32_C(-2), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 137 | EXPECT_EQ(std::byte{3}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 138 | ASSERT_EQ(1u, Encode(INT32_C(2), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 139 | EXPECT_EQ(std::byte{4}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 142 | TEST_F(Varint, EncodeSizeSigned32_SmallSingleByte_C) { |
| 143 | ASSERT_EQ(1u, |
| 144 | pw_VarintCallZigZagEncode(INT32_C(0), buffer_, sizeof(buffer_))); |
| 145 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
| 146 | ASSERT_EQ(1u, |
| 147 | pw_VarintCallZigZagEncode(INT32_C(-1), buffer_, sizeof(buffer_))); |
| 148 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
| 149 | ASSERT_EQ(1u, |
| 150 | pw_VarintCallZigZagEncode(INT32_C(1), buffer_, sizeof(buffer_))); |
| 151 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
| 152 | ASSERT_EQ(1u, |
| 153 | pw_VarintCallZigZagEncode(INT32_C(-2), buffer_, sizeof(buffer_))); |
| 154 | EXPECT_EQ(std::byte{3}, buffer_[0]); |
| 155 | ASSERT_EQ(1u, |
| 156 | pw_VarintCallZigZagEncode(INT32_C(2), buffer_, sizeof(buffer_))); |
| 157 | EXPECT_EQ(std::byte{4}, buffer_[0]); |
| 158 | } |
| 159 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 160 | TEST_F(Varint, EncodeSizeSigned32_LargeSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 161 | ASSERT_EQ(1u, Encode(INT32_C(-63), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 162 | EXPECT_EQ(std::byte{125}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 163 | ASSERT_EQ(1u, Encode(INT32_C(63), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 164 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 165 | ASSERT_EQ(1u, Encode(INT32_C(-64), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 166 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 167 | } |
| 168 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 169 | TEST_F(Varint, EncodeSizeSigned32_LargeSingleByte_C) { |
| 170 | ASSERT_EQ(1u, |
| 171 | pw_VarintCallZigZagEncode(INT32_C(-63), buffer_, sizeof(buffer_))); |
| 172 | EXPECT_EQ(std::byte{125}, buffer_[0]); |
| 173 | ASSERT_EQ(1u, |
| 174 | pw_VarintCallZigZagEncode(INT32_C(63), buffer_, sizeof(buffer_))); |
| 175 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
| 176 | ASSERT_EQ(1u, |
| 177 | pw_VarintCallZigZagEncode(INT32_C(-64), buffer_, sizeof(buffer_))); |
| 178 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
| 179 | } |
| 180 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 181 | TEST_F(Varint, EncodeSizeSigned32_MultiByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 182 | ASSERT_EQ(2u, Encode(INT32_C(64), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 183 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 184 | ASSERT_EQ(2u, Encode(INT32_C(-65), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 185 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 186 | ASSERT_EQ(2u, Encode(INT32_C(65), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 187 | EXPECT_EQ(std::memcmp("\x82\x01", buffer_, 2), 0); |
| 188 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 189 | ASSERT_EQ(5u, Encode(std::numeric_limits<int32_t>::min(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 190 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 191 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 192 | ASSERT_EQ(5u, Encode(std::numeric_limits<int32_t>::max(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 193 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 194 | } |
| 195 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 196 | TEST_F(Varint, EncodeSizeSigned32_MultiByte_C) { |
| 197 | ASSERT_EQ(2u, |
| 198 | pw_VarintCallZigZagEncode(INT32_C(64), buffer_, sizeof(buffer_))); |
| 199 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
| 200 | ASSERT_EQ(2u, |
| 201 | pw_VarintCallZigZagEncode(INT32_C(-65), buffer_, sizeof(buffer_))); |
| 202 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
| 203 | ASSERT_EQ(2u, |
| 204 | pw_VarintCallZigZagEncode(INT32_C(65), buffer_, sizeof(buffer_))); |
| 205 | EXPECT_EQ(std::memcmp("\x82\x01", buffer_, 2), 0); |
| 206 | |
| 207 | ASSERT_EQ(5u, |
| 208 | pw_VarintCallZigZagEncode( |
| 209 | std::numeric_limits<int32_t>::min(), buffer_, sizeof(buffer_))); |
| 210 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 211 | |
| 212 | ASSERT_EQ(5u, |
| 213 | pw_VarintCallZigZagEncode( |
| 214 | std::numeric_limits<int32_t>::max(), buffer_, sizeof(buffer_))); |
| 215 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 216 | } |
| 217 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 218 | TEST_F(Varint, EncodeSizeUnsigned64_SmallSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 219 | ASSERT_EQ(1u, Encode(UINT64_C(0), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 220 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 221 | ASSERT_EQ(1u, Encode(UINT64_C(1), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 222 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 223 | ASSERT_EQ(1u, Encode(UINT64_C(2), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 224 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 225 | } |
| 226 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 227 | TEST_F(Varint, EncodeSizeUnsigned64_SmallSingleByte_C) { |
| 228 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(0), buffer_, sizeof(buffer_))); |
| 229 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
| 230 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(1), buffer_, sizeof(buffer_))); |
| 231 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
| 232 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(2), buffer_, sizeof(buffer_))); |
| 233 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
| 234 | } |
| 235 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 236 | TEST_F(Varint, EncodeSizeUnsigned64_LargeSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 237 | ASSERT_EQ(1u, Encode(UINT64_C(63), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 238 | EXPECT_EQ(std::byte{63}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 239 | ASSERT_EQ(1u, Encode(UINT64_C(64), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 240 | EXPECT_EQ(std::byte{64}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 241 | ASSERT_EQ(1u, Encode(UINT64_C(126), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 242 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 243 | ASSERT_EQ(1u, Encode(UINT64_C(127), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 244 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 245 | } |
| 246 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 247 | TEST_F(Varint, EncodeSizeUnsigned64_LargeSingleByte_C) { |
| 248 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(63), buffer_, sizeof(buffer_))); |
| 249 | EXPECT_EQ(std::byte{63}, buffer_[0]); |
| 250 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(64), buffer_, sizeof(buffer_))); |
| 251 | EXPECT_EQ(std::byte{64}, buffer_[0]); |
| 252 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(126), buffer_, sizeof(buffer_))); |
| 253 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
| 254 | ASSERT_EQ(1u, pw_VarintCallEncode(UINT64_C(127), buffer_, sizeof(buffer_))); |
| 255 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
| 256 | } |
| 257 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 258 | TEST_F(Varint, EncodeSizeUnsigned64_MultiByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 259 | ASSERT_EQ(2u, Encode(UINT64_C(128), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 260 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 261 | ASSERT_EQ(2u, Encode(UINT64_C(129), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 262 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
| 263 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 264 | ASSERT_EQ(5u, Encode(std::numeric_limits<uint32_t>::max() - 1, buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 265 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 266 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 267 | ASSERT_EQ(5u, Encode(std::numeric_limits<uint32_t>::max(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 268 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 269 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 270 | ASSERT_EQ(10u, Encode(std::numeric_limits<uint64_t>::max() - 1, buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 271 | EXPECT_EQ( |
| 272 | std::memcmp("\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 273 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 274 | ASSERT_EQ(10u, Encode(std::numeric_limits<uint64_t>::max(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 275 | EXPECT_EQ( |
| 276 | std::memcmp("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 277 | } |
| 278 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 279 | TEST_F(Varint, EncodeSizeUnsigned64_MultiByte_C) { |
| 280 | ASSERT_EQ(2u, pw_VarintCallEncode(UINT64_C(128), buffer_, sizeof(buffer_))); |
| 281 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
| 282 | ASSERT_EQ(2u, pw_VarintCallEncode(UINT64_C(129), buffer_, sizeof(buffer_))); |
| 283 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
| 284 | |
| 285 | ASSERT_EQ( |
| 286 | 5u, |
| 287 | pw_VarintCallEncode( |
| 288 | std::numeric_limits<uint32_t>::max() - 1, buffer_, sizeof(buffer_))); |
| 289 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 290 | |
| 291 | ASSERT_EQ( |
| 292 | 5u, |
| 293 | pw_VarintCallEncode( |
| 294 | std::numeric_limits<uint32_t>::max(), buffer_, sizeof(buffer_))); |
| 295 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 296 | |
| 297 | ASSERT_EQ( |
| 298 | 10u, |
| 299 | pw_VarintCallEncode( |
| 300 | std::numeric_limits<uint64_t>::max() - 1, buffer_, sizeof(buffer_))); |
| 301 | EXPECT_EQ( |
| 302 | std::memcmp("\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 303 | |
| 304 | ASSERT_EQ( |
| 305 | 10u, |
| 306 | pw_VarintCallEncode( |
| 307 | std::numeric_limits<uint64_t>::max(), buffer_, sizeof(buffer_))); |
| 308 | EXPECT_EQ( |
| 309 | std::memcmp("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 310 | } |
| 311 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 312 | TEST_F(Varint, EncodeSizeSigned64_SmallSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 313 | ASSERT_EQ(1u, Encode(INT64_C(0), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 314 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 315 | ASSERT_EQ(1u, Encode(INT64_C(-1), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 316 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 317 | ASSERT_EQ(1u, Encode(INT64_C(1), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 318 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 319 | ASSERT_EQ(1u, Encode(INT64_C(-2), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 320 | EXPECT_EQ(std::byte{3}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 321 | ASSERT_EQ(1u, Encode(INT64_C(2), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 322 | EXPECT_EQ(std::byte{4}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 325 | TEST_F(Varint, EncodeSizeSigned64_SmallSingleByte_C) { |
| 326 | ASSERT_EQ(1u, |
| 327 | pw_VarintCallZigZagEncode(INT64_C(0), buffer_, sizeof(buffer_))); |
| 328 | EXPECT_EQ(std::byte{0}, buffer_[0]); |
| 329 | ASSERT_EQ(1u, |
| 330 | pw_VarintCallZigZagEncode(INT64_C(-1), buffer_, sizeof(buffer_))); |
| 331 | EXPECT_EQ(std::byte{1}, buffer_[0]); |
| 332 | ASSERT_EQ(1u, |
| 333 | pw_VarintCallZigZagEncode(INT64_C(1), buffer_, sizeof(buffer_))); |
| 334 | EXPECT_EQ(std::byte{2}, buffer_[0]); |
| 335 | ASSERT_EQ(1u, |
| 336 | pw_VarintCallZigZagEncode(INT64_C(-2), buffer_, sizeof(buffer_))); |
| 337 | EXPECT_EQ(std::byte{3}, buffer_[0]); |
| 338 | ASSERT_EQ(1u, |
| 339 | pw_VarintCallZigZagEncode(INT64_C(2), buffer_, sizeof(buffer_))); |
| 340 | EXPECT_EQ(std::byte{4}, buffer_[0]); |
| 341 | } |
| 342 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 343 | TEST_F(Varint, EncodeSizeSigned64_LargeSingleByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 344 | ASSERT_EQ(1u, Encode(INT64_C(-63), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 345 | EXPECT_EQ(std::byte{125}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 346 | ASSERT_EQ(1u, Encode(INT64_C(63), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 347 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 348 | ASSERT_EQ(1u, Encode(INT64_C(-64), buffer_)); |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 349 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 352 | TEST_F(Varint, EncodeSizeSigned64_LargeSingleByte_C) { |
| 353 | ASSERT_EQ(1u, |
| 354 | pw_VarintCallZigZagEncode(INT64_C(-63), buffer_, sizeof(buffer_))); |
| 355 | EXPECT_EQ(std::byte{125}, buffer_[0]); |
| 356 | ASSERT_EQ(1u, |
| 357 | pw_VarintCallZigZagEncode(INT64_C(63), buffer_, sizeof(buffer_))); |
| 358 | EXPECT_EQ(std::byte{126}, buffer_[0]); |
| 359 | ASSERT_EQ(1u, |
| 360 | pw_VarintCallZigZagEncode(INT64_C(-64), buffer_, sizeof(buffer_))); |
| 361 | EXPECT_EQ(std::byte{127}, buffer_[0]); |
| 362 | } |
| 363 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 364 | TEST_F(Varint, EncodeSizeSigned64_MultiByte) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 365 | ASSERT_EQ(2u, Encode(INT64_C(64), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 366 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 367 | ASSERT_EQ(2u, Encode(INT64_C(-65), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 368 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 369 | ASSERT_EQ(2u, Encode(INT64_C(65), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 370 | EXPECT_EQ(std::memcmp("\x82\x01", buffer_, 2), 0); |
| 371 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 372 | ASSERT_EQ(5u, |
| 373 | Encode(static_cast<int64_t>(std::numeric_limits<int32_t>::min()), |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 374 | buffer_)); |
| 375 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 376 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 377 | ASSERT_EQ(5u, |
| 378 | Encode(static_cast<int64_t>(std::numeric_limits<int32_t>::max()), |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 379 | buffer_)); |
| 380 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 381 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 382 | ASSERT_EQ(10u, Encode(std::numeric_limits<int64_t>::min(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 383 | EXPECT_EQ( |
| 384 | std::memcmp("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 385 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 386 | ASSERT_EQ(10u, Encode(std::numeric_limits<int64_t>::max(), buffer_)); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 387 | EXPECT_EQ( |
| 388 | std::memcmp("\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 389 | } |
| 390 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 391 | TEST_F(Varint, EncodeSizeSigned64_MultiByte_C) { |
| 392 | ASSERT_EQ(2u, |
| 393 | pw_VarintCallZigZagEncode(INT64_C(64), buffer_, sizeof(buffer_))); |
| 394 | EXPECT_EQ(std::memcmp("\x80\x01", buffer_, 2), 0); |
| 395 | ASSERT_EQ(2u, |
| 396 | pw_VarintCallZigZagEncode(INT64_C(-65), buffer_, sizeof(buffer_))); |
| 397 | EXPECT_EQ(std::memcmp("\x81\x01", buffer_, 2), 0); |
| 398 | ASSERT_EQ(2u, |
| 399 | pw_VarintCallZigZagEncode(INT64_C(65), buffer_, sizeof(buffer_))); |
| 400 | EXPECT_EQ(std::memcmp("\x82\x01", buffer_, 2), 0); |
| 401 | |
| 402 | ASSERT_EQ(5u, |
| 403 | pw_VarintCallZigZagEncode( |
| 404 | static_cast<int64_t>(std::numeric_limits<int32_t>::min()), |
| 405 | buffer_, |
| 406 | sizeof(buffer_))); |
| 407 | EXPECT_EQ(std::memcmp("\xff\xff\xff\xff\x0f", buffer_, 5), 0); |
| 408 | |
| 409 | ASSERT_EQ(5u, |
| 410 | pw_VarintCallZigZagEncode( |
| 411 | static_cast<int64_t>(std::numeric_limits<int32_t>::max()), |
| 412 | buffer_, |
| 413 | sizeof(buffer_))); |
| 414 | EXPECT_EQ(std::memcmp("\xfe\xff\xff\xff\x0f", buffer_, 5), 0); |
| 415 | |
| 416 | ASSERT_EQ(10u, |
| 417 | pw_VarintCallZigZagEncode( |
| 418 | std::numeric_limits<int64_t>::min(), buffer_, sizeof(buffer_))); |
| 419 | EXPECT_EQ( |
| 420 | std::memcmp("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 421 | |
| 422 | ASSERT_EQ(10u, |
| 423 | pw_VarintCallZigZagEncode( |
| 424 | std::numeric_limits<int64_t>::max(), buffer_, sizeof(buffer_))); |
| 425 | EXPECT_EQ( |
| 426 | std::memcmp("\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01", buffer_, 10), 0); |
| 427 | } |
| 428 | |
Wyatt Hepler | 4681e15 | 2020-02-13 13:19:46 -0800 | [diff] [blame] | 429 | // How much to increment by for each iteration of the exhaustive encode/decode |
| 430 | // tests. Set the increment to 1 to test every number (this is slow). |
| 431 | constexpr int kIncrement = 100'000'009; |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 432 | |
Wyatt Hepler | 4681e15 | 2020-02-13 13:19:46 -0800 | [diff] [blame] | 433 | TEST_F(Varint, EncodeDecodeSigned32) { |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 434 | int32_t i = std::numeric_limits<int32_t>::min(); |
| 435 | while (true) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 436 | size_t encoded = Encode(i, buffer_); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 437 | |
| 438 | int64_t result; |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 439 | size_t decoded = Decode(buffer_, &result); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 440 | |
| 441 | EXPECT_EQ(encoded, decoded); |
| 442 | ASSERT_EQ(i, result); |
| 443 | |
| 444 | if (i > std::numeric_limits<int32_t>::max() - kIncrement) { |
| 445 | break; |
| 446 | } |
| 447 | |
| 448 | i += kIncrement; |
| 449 | } |
| 450 | } |
| 451 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 452 | TEST_F(Varint, EncodeDecodeSigned32_C) { |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 453 | int32_t i = std::numeric_limits<int32_t>::min(); |
| 454 | while (true) { |
| 455 | size_t encoded = pw_VarintCallZigZagEncode(i, buffer_, sizeof(buffer_)); |
| 456 | |
| 457 | int64_t result; |
| 458 | size_t decoded = |
| 459 | pw_VarintCallZigZagDecode(buffer_, sizeof(buffer_), &result); |
| 460 | |
| 461 | EXPECT_EQ(encoded, decoded); |
| 462 | ASSERT_EQ(i, result); |
| 463 | |
| 464 | if (i > std::numeric_limits<int32_t>::max() - kIncrement) { |
| 465 | break; |
| 466 | } |
| 467 | |
| 468 | i += kIncrement; |
| 469 | } |
| 470 | } |
| 471 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 472 | TEST_F(Varint, EncodeDecodeUnsigned32) { |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 473 | uint32_t i = 0; |
| 474 | while (true) { |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 475 | size_t encoded = Encode(i, buffer_); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 476 | |
| 477 | uint64_t result; |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 478 | size_t decoded = Decode(buffer_, &result); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 479 | |
| 480 | EXPECT_EQ(encoded, decoded); |
| 481 | ASSERT_EQ(i, result); |
| 482 | |
| 483 | if (i > std::numeric_limits<uint32_t>::max() - kIncrement) { |
| 484 | break; |
| 485 | } |
| 486 | |
| 487 | i += kIncrement; |
| 488 | } |
| 489 | } |
| 490 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 491 | TEST_F(Varint, EncodeDecodeUnsigned32_C) { |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 492 | uint32_t i = 0; |
| 493 | while (true) { |
| 494 | size_t encoded = pw_VarintCallEncode(i, buffer_, sizeof(buffer_)); |
| 495 | |
| 496 | uint64_t result; |
| 497 | size_t decoded = pw_VarintCallDecode(buffer_, sizeof(buffer_), &result); |
| 498 | |
| 499 | EXPECT_EQ(encoded, decoded); |
| 500 | ASSERT_EQ(i, result); |
| 501 | |
| 502 | if (i > std::numeric_limits<uint32_t>::max() - kIncrement) { |
| 503 | break; |
| 504 | } |
| 505 | |
| 506 | i += kIncrement; |
| 507 | } |
| 508 | } |
| 509 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 510 | template <size_t kStringSize> |
| 511 | auto MakeBuffer(const char (&data)[kStringSize]) { |
| 512 | constexpr size_t kSizeBytes = kStringSize - 1; |
| 513 | static_assert(kSizeBytes <= 10, "Varint arrays never need be larger than 10"); |
| 514 | |
Alexei Frolov | 311c620 | 2020-01-06 11:16:20 -0800 | [diff] [blame] | 515 | std::array<std::byte, kSizeBytes> array; |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 516 | std::memcpy(array.data(), data, kSizeBytes); |
| 517 | return array; |
| 518 | } |
| 519 | |
| 520 | TEST(VarintDecode, DecodeSigned64_SingleByte) { |
| 521 | int64_t value = -1234; |
| 522 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 523 | EXPECT_EQ(Decode(MakeBuffer("\x00"), &value), 1u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 524 | EXPECT_EQ(value, 0); |
| 525 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 526 | EXPECT_EQ(Decode(MakeBuffer("\x01"), &value), 1u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 527 | EXPECT_EQ(value, -1); |
| 528 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 529 | EXPECT_EQ(Decode(MakeBuffer("\x02"), &value), 1u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 530 | EXPECT_EQ(value, 1); |
| 531 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 532 | EXPECT_EQ(Decode(MakeBuffer("\x03"), &value), 1u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 533 | EXPECT_EQ(value, -2); |
| 534 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 535 | EXPECT_EQ(Decode(MakeBuffer("\x04"), &value), 1u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 536 | EXPECT_EQ(value, 2); |
| 537 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 538 | EXPECT_EQ(Decode(MakeBuffer("\x04"), &value), 1u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 539 | EXPECT_EQ(value, 2); |
| 540 | } |
| 541 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 542 | TEST(VarintDecode, DecodeSigned64_SingleByte_C) { |
| 543 | int64_t value = -1234; |
| 544 | |
| 545 | auto buffer = MakeBuffer("\x00"); |
| 546 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer.data(), buffer.size(), &value), |
| 547 | 1u); |
| 548 | EXPECT_EQ(value, 0); |
| 549 | |
| 550 | buffer = MakeBuffer("\x01"); |
| 551 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer.data(), buffer.size(), &value), |
| 552 | 1u); |
| 553 | EXPECT_EQ(value, -1); |
| 554 | |
| 555 | buffer = MakeBuffer("\x02"); |
| 556 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer.data(), buffer.size(), &value), |
| 557 | 1u); |
| 558 | EXPECT_EQ(value, 1); |
| 559 | |
| 560 | buffer = MakeBuffer("\x03"); |
| 561 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer.data(), buffer.size(), &value), |
| 562 | 1u); |
| 563 | EXPECT_EQ(value, -2); |
| 564 | |
| 565 | buffer = MakeBuffer("\x04"); |
| 566 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer.data(), buffer.size(), &value), |
| 567 | 1u); |
| 568 | EXPECT_EQ(value, 2); |
| 569 | |
| 570 | buffer = MakeBuffer("\x04"); |
| 571 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer.data(), buffer.size(), &value), |
| 572 | 1u); |
| 573 | EXPECT_EQ(value, 2); |
| 574 | } |
| 575 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 576 | TEST(VarintDecode, DecodeSigned64_MultiByte) { |
| 577 | int64_t value = -1234; |
| 578 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 579 | EXPECT_EQ(Decode(MakeBuffer("\x80\x01"), &value), 2u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 580 | EXPECT_EQ(value, 64); |
| 581 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 582 | EXPECT_EQ(Decode(MakeBuffer("\x81\x01"), &value), 2u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 583 | EXPECT_EQ(value, -65); |
| 584 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 585 | EXPECT_EQ(Decode(MakeBuffer("\x82\x01"), &value), 2u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 586 | EXPECT_EQ(value, 65); |
| 587 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 588 | EXPECT_EQ(Decode(MakeBuffer("\xff\xff\xff\xff\x0f"), &value), 5u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 589 | EXPECT_EQ(value, std::numeric_limits<int32_t>::min()); |
| 590 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 591 | EXPECT_EQ(Decode(MakeBuffer("\xfe\xff\xff\xff\x0f"), &value), 5u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 592 | EXPECT_EQ(value, std::numeric_limits<int32_t>::max()); |
| 593 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 594 | EXPECT_EQ( |
| 595 | Decode(MakeBuffer("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01"), &value), |
| 596 | 10u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 597 | EXPECT_EQ(value, std::numeric_limits<int64_t>::min()); |
| 598 | |
Alexei Frolov | 65ffd22 | 2020-01-06 14:23:02 -0800 | [diff] [blame] | 599 | EXPECT_EQ( |
| 600 | Decode(MakeBuffer("\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01"), &value), |
| 601 | 10u); |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 602 | EXPECT_EQ(value, std::numeric_limits<int64_t>::max()); |
| 603 | } |
| 604 | |
Alexei Frolov | 8ecefe9 | 2020-01-13 10:40:08 -0800 | [diff] [blame] | 605 | TEST(VarintDecode, DecodeSigned64_MultiByte_C) { |
| 606 | int64_t value = -1234; |
| 607 | |
| 608 | auto buffer2 = MakeBuffer("\x80\x01"); |
| 609 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer2.data(), buffer2.size(), &value), |
| 610 | 2u); |
| 611 | EXPECT_EQ(value, 64); |
| 612 | |
| 613 | buffer2 = MakeBuffer("\x81\x01"); |
| 614 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer2.data(), buffer2.size(), &value), |
| 615 | 2u); |
| 616 | EXPECT_EQ(value, -65); |
| 617 | |
| 618 | buffer2 = MakeBuffer("\x82\x01"); |
| 619 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer2.data(), buffer2.size(), &value), |
| 620 | 2u); |
| 621 | EXPECT_EQ(value, 65); |
| 622 | |
| 623 | auto buffer4 = MakeBuffer("\xff\xff\xff\xff\x0f"); |
| 624 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer4.data(), buffer4.size(), &value), |
| 625 | 5u); |
| 626 | EXPECT_EQ(value, std::numeric_limits<int32_t>::min()); |
| 627 | |
| 628 | buffer4 = MakeBuffer("\xfe\xff\xff\xff\x0f"); |
| 629 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer4.data(), buffer4.size(), &value), |
| 630 | 5u); |
| 631 | EXPECT_EQ(value, std::numeric_limits<int32_t>::max()); |
| 632 | |
| 633 | auto buffer8 = MakeBuffer("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01"); |
| 634 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer8.data(), buffer8.size(), &value), |
| 635 | 10u); |
| 636 | EXPECT_EQ(value, std::numeric_limits<int64_t>::min()); |
| 637 | |
| 638 | buffer8 = MakeBuffer("\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01"); |
| 639 | EXPECT_EQ(pw_VarintCallZigZagDecode(buffer8.data(), buffer8.size(), &value), |
| 640 | 10u); |
| 641 | EXPECT_EQ(value, std::numeric_limits<int64_t>::max()); |
| 642 | } |
| 643 | |
Alexei Frolov | 5d63df9 | 2020-01-06 16:11:15 -0800 | [diff] [blame] | 644 | TEST(Varint, ZigZagEncode_Int8) { |
| 645 | EXPECT_EQ(ZigZagEncode(int8_t(0)), uint8_t(0)); |
| 646 | EXPECT_EQ(ZigZagEncode(int8_t(-1)), uint8_t(1)); |
| 647 | EXPECT_EQ(ZigZagEncode(int8_t(1)), uint8_t(2)); |
| 648 | EXPECT_EQ(ZigZagEncode(int8_t(-2)), uint8_t(3)); |
| 649 | EXPECT_EQ(ZigZagEncode(int8_t(2)), uint8_t(4)); |
| 650 | EXPECT_EQ(ZigZagEncode(int8_t(-33)), uint8_t(65)); |
| 651 | EXPECT_EQ(ZigZagEncode(int8_t(33)), uint8_t(66)); |
| 652 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int8_t>::min()), |
| 653 | std::numeric_limits<uint8_t>::max()); |
| 654 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int8_t>::max()), |
| 655 | std::numeric_limits<uint8_t>::max() - 1u); |
| 656 | } |
| 657 | |
| 658 | TEST(Varint, ZigZagEncode_Int16) { |
| 659 | EXPECT_EQ(ZigZagEncode(int16_t(0)), uint16_t(0)); |
| 660 | EXPECT_EQ(ZigZagEncode(int16_t(-1)), uint16_t(1)); |
| 661 | EXPECT_EQ(ZigZagEncode(int16_t(1)), uint16_t(2)); |
| 662 | EXPECT_EQ(ZigZagEncode(int16_t(-2)), uint16_t(3)); |
| 663 | EXPECT_EQ(ZigZagEncode(int16_t(2)), uint16_t(4)); |
| 664 | EXPECT_EQ(ZigZagEncode(int16_t(-3333)), uint16_t(6665)); |
| 665 | EXPECT_EQ(ZigZagEncode(int16_t(3333)), uint16_t(6666)); |
| 666 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int16_t>::min()), |
| 667 | std::numeric_limits<uint16_t>::max()); |
| 668 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int16_t>::max()), |
| 669 | std::numeric_limits<uint16_t>::max() - 1u); |
| 670 | } |
| 671 | |
| 672 | TEST(Varint, ZigZagEncode_Int32) { |
| 673 | EXPECT_EQ(ZigZagEncode(int32_t(0)), uint32_t(0)); |
| 674 | EXPECT_EQ(ZigZagEncode(int32_t(-1)), uint32_t(1)); |
| 675 | EXPECT_EQ(ZigZagEncode(int32_t(1)), uint32_t(2)); |
| 676 | EXPECT_EQ(ZigZagEncode(int32_t(-2)), uint32_t(3)); |
| 677 | EXPECT_EQ(ZigZagEncode(int32_t(2)), uint32_t(4)); |
| 678 | EXPECT_EQ(ZigZagEncode(int32_t(-128)), uint32_t(255)); |
| 679 | EXPECT_EQ(ZigZagEncode(int32_t(128)), uint32_t(256)); |
| 680 | EXPECT_EQ(ZigZagEncode(int32_t(-333333)), uint32_t(666665)); |
| 681 | EXPECT_EQ(ZigZagEncode(int32_t(333333)), uint32_t(666666)); |
| 682 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int32_t>::min()), |
| 683 | std::numeric_limits<uint32_t>::max()); |
| 684 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int32_t>::max()), |
| 685 | std::numeric_limits<uint32_t>::max() - 1u); |
| 686 | } |
| 687 | |
| 688 | TEST(Varint, ZigZagEncode_Int64) { |
| 689 | EXPECT_EQ(ZigZagEncode(int64_t(0)), uint64_t(0)); |
| 690 | EXPECT_EQ(ZigZagEncode(int64_t(-1)), uint64_t(1)); |
| 691 | EXPECT_EQ(ZigZagEncode(int64_t(1)), uint64_t(2)); |
| 692 | EXPECT_EQ(ZigZagEncode(int64_t(-2)), uint64_t(3)); |
| 693 | EXPECT_EQ(ZigZagEncode(int64_t(2)), uint64_t(4)); |
| 694 | EXPECT_EQ(ZigZagEncode(int64_t(-3333333333)), uint64_t(6666666665)); |
| 695 | EXPECT_EQ(ZigZagEncode(int64_t(3333333333)), uint64_t(6666666666)); |
| 696 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int64_t>::min()), |
| 697 | std::numeric_limits<uint64_t>::max()); |
| 698 | EXPECT_EQ(ZigZagEncode(std::numeric_limits<int64_t>::max()), |
| 699 | std::numeric_limits<uint64_t>::max() - 1u); |
| 700 | } |
| 701 | |
| 702 | TEST(Varint, ZigZagDecode_Int8) { |
| 703 | EXPECT_EQ(ZigZagDecode(uint8_t(0)), int8_t(0)); |
| 704 | EXPECT_EQ(ZigZagDecode(uint8_t(1)), int8_t(-1)); |
| 705 | EXPECT_EQ(ZigZagDecode(uint8_t(2)), int8_t(1)); |
| 706 | EXPECT_EQ(ZigZagDecode(uint8_t(3)), int8_t(-2)); |
| 707 | EXPECT_EQ(ZigZagDecode(uint8_t(4)), int8_t(2)); |
| 708 | EXPECT_EQ(ZigZagDecode(uint8_t(65)), int8_t(-33)); |
| 709 | EXPECT_EQ(ZigZagDecode(uint8_t(66)), int8_t(33)); |
| 710 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint8_t>::max()), |
| 711 | std::numeric_limits<int8_t>::min()); |
| 712 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint8_t>::max() - 1u), |
| 713 | std::numeric_limits<int8_t>::max()); |
| 714 | } |
| 715 | |
| 716 | TEST(Varint, ZigZagDecode_Int16) { |
| 717 | EXPECT_EQ(ZigZagDecode(uint16_t(0)), int16_t(0)); |
| 718 | EXPECT_EQ(ZigZagDecode(uint16_t(1)), int16_t(-1)); |
| 719 | EXPECT_EQ(ZigZagDecode(uint16_t(2)), int16_t(1)); |
| 720 | EXPECT_EQ(ZigZagDecode(uint16_t(3)), int16_t(-2)); |
| 721 | EXPECT_EQ(ZigZagDecode(uint16_t(4)), int16_t(2)); |
| 722 | EXPECT_EQ(ZigZagDecode(uint16_t(6665)), int16_t(-3333)); |
| 723 | EXPECT_EQ(ZigZagDecode(uint16_t(6666)), int16_t(3333)); |
| 724 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint16_t>::max()), |
| 725 | std::numeric_limits<int16_t>::min()); |
| 726 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint16_t>::max() - 1u), |
| 727 | std::numeric_limits<int16_t>::max()); |
| 728 | } |
| 729 | |
| 730 | TEST(Varint, ZigZagDecode_Int32) { |
| 731 | EXPECT_EQ(ZigZagDecode(uint32_t(0)), int32_t(0)); |
| 732 | EXPECT_EQ(ZigZagDecode(uint32_t(1)), int32_t(-1)); |
| 733 | EXPECT_EQ(ZigZagDecode(uint32_t(2)), int32_t(1)); |
| 734 | EXPECT_EQ(ZigZagDecode(uint32_t(3)), int32_t(-2)); |
| 735 | EXPECT_EQ(ZigZagDecode(uint32_t(4)), int32_t(2)); |
| 736 | EXPECT_EQ(ZigZagDecode(uint32_t(255)), int32_t(-128)); |
| 737 | EXPECT_EQ(ZigZagDecode(uint32_t(256)), int32_t(128)); |
| 738 | EXPECT_EQ(ZigZagDecode(uint32_t(666665)), int32_t(-333333)); |
| 739 | EXPECT_EQ(ZigZagDecode(uint32_t(666666)), int32_t(333333)); |
| 740 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint32_t>::max()), |
| 741 | std::numeric_limits<int32_t>::min()); |
| 742 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint32_t>::max() - 1u), |
| 743 | std::numeric_limits<int32_t>::max()); |
| 744 | } |
| 745 | |
| 746 | TEST(Varint, ZigZagDecode_Int64) { |
| 747 | EXPECT_EQ(ZigZagDecode(uint64_t(0)), int64_t(0)); |
| 748 | EXPECT_EQ(ZigZagDecode(uint64_t(1)), int64_t(-1)); |
| 749 | EXPECT_EQ(ZigZagDecode(uint64_t(2)), int64_t(1)); |
| 750 | EXPECT_EQ(ZigZagDecode(uint64_t(3)), int64_t(-2)); |
| 751 | EXPECT_EQ(ZigZagDecode(uint64_t(4)), int64_t(2)); |
| 752 | EXPECT_EQ(ZigZagDecode(uint64_t(6666666665)), int64_t(-3333333333)); |
| 753 | EXPECT_EQ(ZigZagDecode(uint64_t(6666666666)), int64_t(3333333333)); |
| 754 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint64_t>::max()), |
| 755 | std::numeric_limits<int64_t>::min()); |
| 756 | EXPECT_EQ(ZigZagDecode(std::numeric_limits<uint64_t>::max() - 1llu), |
| 757 | std::numeric_limits<int64_t>::max()); |
| 758 | } |
| 759 | |
| 760 | TEST(Varint, ZigZagEncodeDecode) { |
| 761 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(0)), 0); |
| 762 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(1)), 1); |
| 763 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(-1)), -1); |
| 764 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(8675309)), 8675309); |
| 765 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int8_t>::min())), |
| 766 | std::numeric_limits<int8_t>::min()); |
| 767 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int8_t>::max())), |
| 768 | std::numeric_limits<int8_t>::max()); |
| 769 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int16_t>::min())), |
| 770 | std::numeric_limits<int16_t>::min()); |
| 771 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int16_t>::max())), |
| 772 | std::numeric_limits<int16_t>::max()); |
| 773 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int32_t>::min())), |
| 774 | std::numeric_limits<int32_t>::min()); |
| 775 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int32_t>::max())), |
| 776 | std::numeric_limits<int32_t>::max()); |
| 777 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int64_t>::min())), |
| 778 | std::numeric_limits<int64_t>::min()); |
| 779 | EXPECT_EQ(ZigZagDecode(ZigZagEncode(std::numeric_limits<int64_t>::max())), |
| 780 | std::numeric_limits<int64_t>::max()); |
| 781 | } |
| 782 | |
Alexei Frolov | 82d3cb3 | 2019-11-27 14:38:39 -0800 | [diff] [blame] | 783 | } // namespace |
| 784 | } // namespace pw::varint |