mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
[coding] Added varint short arrays ser/des.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com> # Conflicts: # libs/coding/coding_tests/varint_test.cpp
This commit is contained in:
committed by
Konstantin Pastbin
parent
111e913478
commit
25a4a3b76f
@@ -1,7 +1,8 @@
|
||||
#include "coding/varint.hpp"
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/byte_stream.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/varint.hpp"
|
||||
|
||||
#include "base/macros.hpp"
|
||||
#include "base/stl_helpers.hpp"
|
||||
@@ -185,3 +186,29 @@ UNIT_TEST(ReadVarInt64Array)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(VarInt_ShortSortedArray)
|
||||
{
|
||||
uint32_t constexpr maxVal = (uint32_t(1) << 30) - 1;
|
||||
std::vector<uint32_t> samples[] = {
|
||||
{0},
|
||||
{10, 10000},
|
||||
{maxVal - 2, maxVal - 1, maxVal},
|
||||
};
|
||||
|
||||
for (auto const & s : samples)
|
||||
{
|
||||
std::vector<uint8_t> buffer;
|
||||
PushBackByteSink sink(buffer);
|
||||
|
||||
WriteVarUInt32SortedShortArray(s, sink);
|
||||
|
||||
MemReader reader(buffer.data(), buffer.size());
|
||||
ReaderSource src(reader);
|
||||
|
||||
std::vector<uint32_t> actual;
|
||||
ReadVarUInt32SortedShortArray(src, actual);
|
||||
|
||||
TEST_EQUAL(s, actual, ());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user