Browse Source

test: core test demo

master
Dnomd343 2 years ago
parent
commit
35f94e4c54
  1. 28
      test/CMakeLists.txt
  2. 40
      test/core/core.cc

28
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)
################################################################################

40
test/core/core.cc

@ -0,0 +1,40 @@
#include <unordered_set>
#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<uint64_t>();
// auto raw_codes_ = std::vector<uint64_t>();
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));
}
);
for (auto &&raw_code : raw_codes) {
core.next_cases(raw_code, 0);
}
// EXPECT_EQ(raw_codes.size(), 29334498);
}
Loading…
Cancel
Save