From e2ddcd4c766f9974e120c900e3f0bccfed79c673 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Mon, 30 Jan 2023 17:49:31 +0800 Subject: [PATCH] test: add ffi codec warm up test --- test/CMakeLists.txt | 2 +- test/ffi/codec.cc | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/ffi/codec.cc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 39bb190..1560c0a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -40,7 +40,7 @@ add_test(NAME codec COMMAND test_codec) include_directories(../src/klotski_core) include_directories(../src/klotski_core/utils) -set(TEST_FFI_SRC metadata.cc all_cases.cc) +set(TEST_FFI_SRC metadata.cc codec.cc all_cases.cc) list(TRANSFORM TEST_FFI_SRC PREPEND "ffi/") add_executable(test_ffi ${TEST_FFI_SRC}) target_link_libraries(test_ffi ${TEST_DEPS}) diff --git a/test/ffi/codec.cc b/test/ffi/codec.cc new file mode 100644 index 0000000..11baa63 --- /dev/null +++ b/test/ffi/codec.cc @@ -0,0 +1,22 @@ +#include "klotski.h" +#include "all_cases.h" +#include "short_code.h" +#include "gtest/gtest.h" + +using klotski::AllCases; +using klotski::ShortCode; +using klotski::BasicRanges; + +TEST(FFI, codec_warm_up) { + // short code normal mode check + EXPECT_EQ(is_short_code_available(), BasicRanges::status() == BasicRanges::AVAILABLE); + short_code_enable(); + EXPECT_EQ(is_short_code_available(), true); + EXPECT_EQ(is_short_code_available(), BasicRanges::status() == BasicRanges::AVAILABLE); + + // short code fast mode check + EXPECT_EQ(is_short_code_available_fast(), AllCases::status() == AllCases::AVAILABLE); + short_code_enable_fast(); + EXPECT_EQ(is_short_code_available_fast(), true); + EXPECT_EQ(is_short_code_available_fast(), AllCases::status() == AllCases::AVAILABLE); +}