Add test for size_varint

This commit is contained in:
Howard Hinnant
2017-11-02 15:36:39 -04:00
committed by Nikolaos D. Bougalis
parent 7ff6d34a49
commit d8bbcf21be

View File

@@ -35,17 +35,12 @@ public:
testcase("encode, decode");
for (auto const v : vv)
{
std::array<std::uint8_t,
varint_traits<
std::size_t>::max> vi;
auto const n0 =
write_varint(
vi.data(), v);
std::array<std::uint8_t, varint_traits<std::size_t>::max> vi;
auto const n0 = write_varint(vi.data(), v);
expect (n0 > 0, "write error");
expect(n0 == size_varint(v), "size error");
std::size_t v1;
auto const n1 =
read_varint(
vi.data(), n0, v1);
auto const n1 = read_varint(vi.data(), n0, v1);
expect(n1 == n0, "read error");
expect(v == v1, "wrong value");
}