MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_TEST

Function UNIT_TEST

libs/coding/coding_tests/sparse_vector_tests.cpp:5–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "coding/sparse_vector.hpp"
4
5UNIT_TEST(SparseVector_Smoke)
6{
7 uint32_t const arr[] = {0, 0, 5, 0, 7, 1000, 0, 0, 1, 0};
8 uint64_t const count = std::size(arr);
9
10 coding::SparseVectorBuilder<uint32_t> builder(count);
11 for (uint32_t v : arr)
12 if (v == 0)
13 builder.PushEmpty();
14 else
15 builder.PushValue(v);
16
17 auto vec = builder.Build();
18
19 TEST_EQUAL(vec.GetSize(), count, ());
20 for (size_t i = 0; i < count; ++i)
21 {
22 TEST_EQUAL(vec.Has(i), (arr[i] != 0), ());
23 if (arr[i] != 0)
24 TEST_EQUAL(vec.Get(i), arr[i], ());
25 }
26}

Callers

nothing calls this directly

Calls 7

sizeFunction · 0.85
PushEmptyMethod · 0.80
PushValueMethod · 0.80
BuildMethod · 0.45
GetSizeMethod · 0.45
HasMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected