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 <gtest/gtest.h> |
||||
|
|
||||
#include <format> |
|
||||
|
|
||||
#include "hash.h" |
|
||||
#include "helper/cases.h" |
#include "helper/cases.h" |
||||
|
#include "utility/hash.h" |
||||
#include "ranges/ranges.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"; |
constexpr std::string_view ALL_CASES_MD5 = "3888e9fab8d3cbb50908b12b147cfb23"; |
||||
|
|
||||
|
static_assert(std::is_base_of_v<std::array<Ranges, 16>, RangesUnion>); |
||||
|
|
||||
TEST(RangesUnion, export) { |
TEST(RangesUnion, export) { |
||||
std::string buffer; |
std::string buffer; |
||||
|
buffer.reserve(ALL_CASES_NUM_ * 10); // [\dA-F]{9} + '\n'
|
||||
for (auto code : AllCases::instance().fetch().codes()) { |
for (auto code : AllCases::instance().fetch().codes()) { |
||||
buffer += std::format("{:09X}\n", code.unwrap()); |
buffer += std::format("{:09X}\n", code.unwrap()); |
||||
} |
} |
||||
EXPECT_EQ(hash::md5(buffer), ALL_CASES_MD5); |
EXPECT_EQ(hash::md5(buffer), ALL_CASES_MD5); |
||||
} |
} |
||||
|
|
||||
TEST(RangesUnion, operator) { |
TEST(RangesUnion, append) { |
||||
Ranges r, r1, r2; |
RangesUnion cases; |
||||
r.spawn(5, 3, 4); |
for (auto [n, n_2x1, n_1x1] : BLOCK_NUM) { |
||||
r.spawn(5, 4, 4); |
Ranges r; |
||||
r1.spawn(5, 3, 4); |
r.spawn(n, n_2x1, n_1x1); |
||||
r2.spawn(5, 4, 4); |
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) { |
for (const auto head : Heads) { |
||||
r.derive(head, r_[head]); |
std::stable_sort(cases[head].begin(), cases[head].end()); |
||||
r1.derive(head, r1_[head]); |
|
||||
r2.derive(head, r2_[head]); |
|
||||
} |
} |
||||
EXPECT_EQ(r_, r1_ += r2_); |
EXPECT_EQ(cases, AllCases::instance().fetch()); |
||||
} |
} |
||||
|
Loading…
Reference in new issue