Browse Source

test: more test suites for BasicRanges

legacy
Dnomd343 7 months ago
parent
commit
396a7fe4bc
  1. 25
      src/core_test/cases/basic_ranges.cc
  2. 4
      src/core_test/cases/helper.h

25
src/core_test/cases/basic_ranges.cc

@ -1,5 +1,9 @@
#include "hash.h" #include "hash.h"
#include "helper.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; 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) { TEST_FF(BasicRanges, constant) {
// TODO: check BASIC_RANGES_NUM array
EXPECT_EQ(BASIC_RANGES_NUM_, 7311885); 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) { TEST_FF(BasicRanges, basic_ranges) {

4
src/core_test/cases/helper.h

@ -1,10 +1,14 @@
#pragma once #pragma once
#include <algorithm>
#include "exposer.h" #include "exposer.h"
#include "all_cases.h" #include "all_cases.h"
#include "concurrent.h" #include "concurrent.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
using klotski::array_sum;
using klotski::cases::AllCases; using klotski::cases::AllCases;
using klotski::cases::BasicRanges; using klotski::cases::BasicRanges;

Loading…
Cancel
Save