mirror of https://github.com/dnomd343/klotski.git
Dnomd343
3 months ago
4 changed files with 36 additions and 39 deletions
@ -1,35 +1,39 @@ |
|||
#include <gtest/gtest.h> |
|||
|
|||
#include <format> |
|||
|
|||
#include "hash.h" |
|||
#include "helper/cases.h" |
|||
#include "utility/hash.h" |
|||
#include "ranges/ranges.h" |
|||
|
|||
static_assert(std::is_base_of_v<std::array<Ranges, 16>, RangesUnion>); |
|||
|
|||
constexpr std::string_view ALL_CASES_MD5 = "3888e9fab8d3cbb50908b12b147cfb23"; |
|||
|
|||
static_assert(std::is_base_of_v<std::array<Ranges, 16>, RangesUnion>); |
|||
|
|||
TEST(RangesUnion, export) { |
|||
std::string buffer; |
|||
buffer.reserve(ALL_CASES_NUM_ * 10); // [\dA-F]{9} + '\n'
|
|||
for (auto code : AllCases::instance().fetch().codes()) { |
|||
buffer += std::format("{:09X}\n", code.unwrap()); |
|||
} |
|||
EXPECT_EQ(hash::md5(buffer), ALL_CASES_MD5); |
|||
} |
|||
|
|||
TEST(RangesUnion, operator) { |
|||
Ranges r, r1, r2; |
|||
r.spawn(5, 3, 4); |
|||
r.spawn(5, 4, 4); |
|||
r1.spawn(5, 3, 4); |
|||
r2.spawn(5, 4, 4); |
|||
TEST(RangesUnion, append) { |
|||
RangesUnion cases; |
|||
for (auto [n, n_2x1, n_1x1] : BLOCK_NUM) { |
|||
Ranges r; |
|||
r.spawn(n, n_2x1, n_1x1); |
|||
r.reverse(); |
|||
|
|||
RangesUnion ru; |
|||
for (const auto head : Heads) { |
|||
r.derive(head, ru[head]); |
|||
} |
|||
auto &tmp = cases += ru; |
|||
EXPECT_EQ(tmp, cases); // reference of cases
|
|||
} |
|||
|
|||
RangesUnion r_, r1_, r2_; |
|||
for (const auto head : Heads) { |
|||
r.derive(head, r_[head]); |
|||
r1.derive(head, r1_[head]); |
|||
r2.derive(head, r2_[head]); |
|||
std::stable_sort(cases[head].begin(), cases[head].end()); |
|||
} |
|||
EXPECT_EQ(r_, r1_ += r2_); |
|||
EXPECT_EQ(cases, AllCases::instance().fetch()); |
|||
} |
|||
|
Loading…
Reference in new issue