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:
28
coding/coding_tests/sparse_vector_tests.cpp
Normal file
28
coding/coding_tests/sparse_vector_tests.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/sparse_vector.hpp"
|
||||
|
||||
UNIT_TEST(SparseVector_Smoke)
|
||||
{
|
||||
uint32_t const arr[] = { 0, 0, 5, 0, 7, 1000, 0, 0, 1, 0 };
|
||||
uint64_t const count = std::size(arr);
|
||||
|
||||
coding::SparseVectorBuilder<uint32_t> builder(count);
|
||||
for (uint32_t v : arr)
|
||||
{
|
||||
if (v == 0)
|
||||
builder.PushEmpty();
|
||||
else
|
||||
builder.PushValue(v);
|
||||
}
|
||||
|
||||
auto vec = builder.Build();
|
||||
|
||||
TEST_EQUAL(vec.GetSize(), count, ());
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
TEST_EQUAL(vec.Has(i), (arr[i] != 0), ());
|
||||
if (arr[i] != 0)
|
||||
TEST_EQUAL(vec.Get(i), arr[i], ());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user