mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 22:53:43 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
60
indexer/indexer_tests/complex_serdes_utils_tests.cpp
Normal file
60
indexer/indexer_tests/complex_serdes_utils_tests.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "indexer/complex/serdes_utils.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/writer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
using ByteVector = std::vector<uint8_t>;
|
||||
|
||||
template <typename Cont>
|
||||
void CollectionPrimitiveTest(Cont const & cont)
|
||||
{
|
||||
ByteVector buffer;
|
||||
MemWriter<decltype(buffer)> writer(buffer);
|
||||
WriterSink<decltype(writer)> sink(writer);
|
||||
coding_utils::WriteCollectionPrimitive(sink, cont);
|
||||
|
||||
MemReader reader(buffer.data(), buffer.size());
|
||||
ReaderSource<decltype(reader)> src(reader);
|
||||
Cont res;
|
||||
coding_utils::ReadCollectionPrimitive(src, std::inserter(res, std::end(res)));
|
||||
TEST_EQUAL(cont, res, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(Utils_CollectionPrimitive)
|
||||
{
|
||||
{
|
||||
std::list<uint8_t> const cont{1, 2, 3, 4};
|
||||
CollectionPrimitiveTest(cont);
|
||||
}
|
||||
{
|
||||
std::list<int8_t> const cont{-1, -2, -3, -4};
|
||||
CollectionPrimitiveTest(cont);
|
||||
}
|
||||
{
|
||||
std::vector<uint32_t> const cont{1, 2, 3, 4};
|
||||
CollectionPrimitiveTest(cont);
|
||||
}
|
||||
{
|
||||
std::vector<int32_t> const cont{-1, -2, -3, -4};
|
||||
CollectionPrimitiveTest(cont);
|
||||
}
|
||||
{
|
||||
std::set<uint64_t> const cont{1, 2, 3, 4};
|
||||
CollectionPrimitiveTest(cont);
|
||||
}
|
||||
{
|
||||
std::set<int64_t> const cont{-1, -2, -3, -4};
|
||||
CollectionPrimitiveTest(cont);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user