#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include #include "doctest/doctest.h" std::vector make_random_ints(std::uint64_t n) { static constexpr std::uint64_t seed = 13; std::mt19937_64 engine(seed); std::uniform_int_distribution dist(0, UINT16_MAX); std::vector ints(n); for (std::uint64_t i = 0; i < n; i++) { ints[i] = dist(engine); } return ints; } TEST_CASE("Test xcdat::compact_vector (tiny)") { std::vector ints = {2, 0, 14, 456, 32, 5544, 23}; xcdat::compact_vector cv(ints); REQUIRE_EQ(cv.size(), ints.size()); for (std::uint64_t i = 0; i < ints.size(); i++) { REQUIRE_EQ(cv[i], ints[i]); } } TEST_CASE("Test xcdat::compact_vector (random)") { std::vector ints = make_random_ints(10000); xcdat::compact_vector cv(ints); REQUIRE_EQ(cv.size(), ints.size()); for (std::uint64_t i = 0; i < ints.size(); i++) { REQUIRE_EQ(cv[i], ints[i]); } }