From 396a7fe4bc107ccebecd2bca0b632f747250290b Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 2 Jun 2024 14:28:36 +0800 Subject: [PATCH] test: more test suites for BasicRanges --- src/core_test/cases/basic_ranges.cc | 25 ++++++++++++++++++++++++- src/core_test/cases/helper.h | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/core_test/cases/basic_ranges.cc b/src/core_test/cases/basic_ranges.cc index 68964c0..f0e1742 100644 --- a/src/core_test/cases/basic_ranges.cc +++ b/src/core_test/cases/basic_ranges.cc @@ -1,5 +1,9 @@ #include "hash.h" #include "helper.h" +#include "group/group.h" + +using klotski::cases::Ranges; +using klotski::cases::BLOCK_NUM; static constexpr uint64_t BASIC_RANGES_XXH3 = 0x34fce9da6a052533; @@ -28,9 +32,28 @@ protected: } }; +TEST_FF(BasicRanges, content) { + auto &ranges = BasicRanges::instance().fetch(); + + EXPECT_TRUE(std::ranges::is_sorted(ranges.begin(), ranges.end())); + const auto match = std::ranges::adjacent_find(ranges.begin(), ranges.end()); + EXPECT_EQ(match, ranges.end()); // no duplicates + + EXPECT_EQ(ranges.size(), BASIC_RANGES_NUM_); // size verify + EXPECT_EQ(hash::xxh3(ranges), BASIC_RANGES_XXH3); // checksum verify +} + TEST_FF(BasicRanges, constant) { - // TODO: check BASIC_RANGES_NUM array EXPECT_EQ(BASIC_RANGES_NUM_, 7311885); + EXPECT_EQ(array_sum(BASIC_RANGES_NUM), BASIC_RANGES_NUM_); + + Ranges ranges; + for (uint32_t type_id = 0; type_id < klotski::cases::TYPE_ID_LIMIT; ++type_id) { + auto [n, n_2x1, n_1x1] = BLOCK_NUM[type_id]; + ranges.clear(); + ranges.spawn(n, n_2x1, n_1x1); + EXPECT_EQ(ranges.size(), BASIC_RANGES_NUM[type_id]); + } } TEST_FF(BasicRanges, basic_ranges) { diff --git a/src/core_test/cases/helper.h b/src/core_test/cases/helper.h index 374e29c..155a689 100644 --- a/src/core_test/cases/helper.h +++ b/src/core_test/cases/helper.h @@ -1,10 +1,14 @@ #pragma once +#include + #include "exposer.h" #include "all_cases.h" #include "concurrent.h" #include "gtest/gtest.h" +using klotski::array_sum; + using klotski::cases::AllCases; using klotski::cases::BasicRanges;