From 35f94e4c544b458302caa47f6ab04513e131c21f Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 8 Apr 2023 22:11:42 +0800 Subject: [PATCH] test: core test demo --- test/CMakeLists.txt | 28 +++++++++++++--------------- test/core/core.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 test/core/core.cc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 20590e9..223af00 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,6 +43,19 @@ add_test(NAME codec COMMAND test_codec) ################################################################################ +include_directories(../src/klotski_core/core) +include_directories(../src/klotski_core/raw_code) +include_directories(../src/klotski_core/all_cases) +include_directories(../src/klotski_core/common_code) + +set(TEST_CORE_SRC core.cc) +list(TRANSFORM TEST_CORE_SRC PREPEND "core/") +add_executable(test_core ${TEST_CORE_SRC}) +target_link_libraries(test_core ${TEST_DEPS}) +add_test(NAME core COMMAND test_core) + +################################################################################ + include_directories(../src/klotski_core) include_directories(../src/klotski_core/utils) @@ -66,19 +79,4 @@ add_executable(test_codec_global global/short_code.cc global/common_code.cc glob target_link_libraries(test_codec_global ${TEST_GLOBAL_DEPS}) add_test(NAME codec_global COMMAND test_codec_global) -#include_directories(../src/klotski_core/common_code) -#add_executable(test_global_common_code global/common_code.cc) -#target_link_libraries(test_global_common_code ${TEST_GLOBAL_DEPS}) -#add_test(NAME global_common_code COMMAND test_global_common_code) -# -#include_directories(../src/klotski_core/short_code) -#add_executable(test_global_short_code global/short_code.cc) -#target_link_libraries(test_global_short_code ${TEST_GLOBAL_DEPS}) -#add_test(NAME global_short_code COMMAND test_global_short_code) -# -#include_directories(../src/klotski_core/raw_code) -#add_executable(test_global_raw_code global/raw_code.cc) -#target_link_libraries(test_global_raw_code ${TEST_GLOBAL_DEPS}) -#add_test(NAME global_raw_code COMMAND test_global_raw_code) - ################################################################################ diff --git a/test/core/core.cc b/test/core/core.cc new file mode 100644 index 0000000..054e471 --- /dev/null +++ b/test/core/core.cc @@ -0,0 +1,40 @@ +#include +#include "core.h" +#include "all_cases.h" +#include "gtest/gtest.h" + +using klotski::RawCode; +using klotski::AllCases; + +TEST(Core, demo) { + auto raw_codes = std::unordered_set(); +// auto raw_codes_ = std::vector(); + + 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(code), std::forward(mask)); + } + ); + + + for (auto &&raw_code : raw_codes) { + core.next_cases(raw_code, 0); + } + + +// EXPECT_EQ(raw_codes.size(), 29334498); +}