mirror of https://github.com/dnomd343/klotski.git
Dnomd343
2 years ago
2 changed files with 23 additions and 28 deletions
@ -1,40 +1,35 @@ |
|||
#include <unordered_set> |
|||
#include "core.h" |
|||
#include "group.h" |
|||
#include "all_cases.h" |
|||
#include "gtest/gtest.h" |
|||
|
|||
using klotski::Group; |
|||
using klotski::RawCode; |
|||
using klotski::AllCases; |
|||
|
|||
TEST(Core, demo) { |
|||
auto raw_codes = std::unordered_set<uint64_t>(); |
|||
// auto raw_codes_ = std::vector<uint64_t>();
|
|||
using klotski::TYPE_ID_LIMIT; |
|||
|
|||
raw_codes.reserve(klotski::ALL_CASES_SIZE_SUM); |
|||
// raw_codes_.reserve(klotski::ALL_CASES_SIZE_SUM);
|
|||
|
|||
for (auto &&common_code : AllCases::release()) { // load all raw codes
|
|||
|
|||
// EXPECT_NE(common_code.to_raw_code(), 0);
|
|||
|
|||
raw_codes.emplace(common_code.to_raw_code().unwrap()); |
|||
// raw_codes_.emplace_back(common_code.to_raw_code().unwrap());
|
|||
} |
|||
|
|||
std::cout << "init ok" << std::endl; |
|||
|
|||
auto core = klotski::Core( |
|||
[&raw_codes](auto &&code, auto &&mask) { |
|||
EXPECT_NE(raw_codes.find(code), raw_codes.end()); |
|||
// new_case(std::forward<decltype(code)>(code), std::forward<decltype(mask)>(mask));
|
|||
TEST(Core, next_cases) { |
|||
auto test = [](uint32_t type_id) { |
|||
auto raw_codes = std::unordered_set<uint64_t>(); |
|||
raw_codes.reserve(klotski::ALL_CASES_SIZE_SUM); |
|||
for (auto &&common_code: Group::all_cases(type_id)) { // load all cases in a type
|
|||
raw_codes.emplace(common_code.to_raw_code().unwrap()); |
|||
} |
|||
); |
|||
|
|||
|
|||
for (auto &&raw_code : raw_codes) { |
|||
core.next_cases(raw_code, 0); |
|||
auto core = klotski::Core( |
|||
[&raw_codes](auto &&code, auto &&mask) { |
|||
EXPECT_NE(raw_codes.find(code), raw_codes.end()); // verify next case
|
|||
EXPECT_EQ(mask >> __builtin_ctzll(mask), 0b111); // verify mask
|
|||
} |
|||
); |
|||
for (auto &&raw_code: raw_codes) { |
|||
core.next_cases(raw_code, 0); // search next cases
|
|||
} |
|||
}; |
|||
// TODO: using multi-threads
|
|||
for (uint32_t type_id = 0; type_id < TYPE_ID_LIMIT; ++type_id) { |
|||
test(type_id); |
|||
} |
|||
|
|||
|
|||
// EXPECT_EQ(raw_codes.size(), 29334498);
|
|||
} |
|||
|
Loading…
Reference in new issue