mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +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:
55
coding/coding_tests/succinct_mapper_test.cpp
Normal file
55
coding/coding_tests/succinct_mapper_test.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/succinct_mapper.hpp"
|
||||
#include "coding/writer.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "3party/succinct/mapper.hpp"
|
||||
|
||||
using namespace coding;
|
||||
|
||||
UNIT_TEST(ReverseMapper_Smoke)
|
||||
{
|
||||
uint64_t data = 0x0123456789abcdef;
|
||||
uint64_t rdata = 0x0;
|
||||
TEST_EQUAL(8, ReverseMap(rdata, reinterpret_cast<uint8_t *>(&data), "uint64_t"), ());
|
||||
|
||||
// Test that reversed uint64_t was read.
|
||||
TEST_EQUAL(0xefcdab8967452301, rdata, ());
|
||||
|
||||
// Test that underlying buffer was modified.
|
||||
TEST_EQUAL(0xefcdab8967452301, data, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(Freeze_Smoke)
|
||||
{
|
||||
std::vector<uint8_t> data;
|
||||
{
|
||||
MemWriter<decltype(data)> writer(data);
|
||||
uint64_t const data = 0x0123456789abcdef;
|
||||
Freeze(data, writer, "uint64_t");
|
||||
}
|
||||
TEST_EQUAL(8, data.size(), ());
|
||||
|
||||
uint64_t value = 0x0;
|
||||
TEST_EQUAL(8, Map(value, reinterpret_cast<uint8_t const *>(data.data()), "uint64_t"), ());
|
||||
TEST_EQUAL(0x0123456789abcdef, value, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(ReverseFreeze_Smoke)
|
||||
{
|
||||
std::vector<uint8_t> data;
|
||||
{
|
||||
MemWriter<decltype(data)> writer(data);
|
||||
uint64_t const data = 0x0123456789abcdef;
|
||||
ReverseFreeze(data, writer, "uint64_t");
|
||||
}
|
||||
|
||||
TEST_EQUAL(8, data.size(), ());
|
||||
|
||||
uint64_t value = 0x0;
|
||||
TEST_EQUAL(8, Map(value, reinterpret_cast<uint8_t const *>(data.data()), "uint64_t"), ());
|
||||
TEST_EQUAL(0xefcdab8967452301, value, ());
|
||||
}
|
||||
Reference in New Issue
Block a user