From 6f67d649cf0e9a65557fe7b0b18d90cefa03e41e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 8 Apr 2023 14:21:16 +0800 Subject: [PATCH] test: update basic test items --- test/basic/all_cases.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/basic/all_cases.cc b/test/basic/all_cases.cc index 140b20f..60e19d0 100644 --- a/test/basic/all_cases.cc +++ b/test/basic/all_cases.cc @@ -5,6 +5,7 @@ using klotski::AllCases; using klotski::BasicRanges; + using klotski::ALL_CASES_SIZE; using klotski::BASIC_RANGES_SIZE; using klotski::ALL_CASES_SIZE_SUM; @@ -38,7 +39,7 @@ TEST(AllCases, basic_ranges_size) { /// basic ranges data verify TEST(AllCases, basic_ranges_data) { - auto *basic_ranges_data = new char[BASIC_RANGES_SIZE * 9]; + auto *basic_ranges_data = new char[BASIC_RANGES_SIZE * 9 + 1]; // 8-bit + '\n' auto *current = basic_ranges_data; for (const auto &range : BasicRanges::fetch()) { sprintf(current, "%08X\n", range); @@ -73,7 +74,7 @@ TEST(AllCases, all_cases_size) { /// all cases data verify TEST(AllCases, all_cases_data) { - auto *all_cases_data = new char[ALL_CASES_SIZE_SUM * 10]; + auto *all_cases_data = new char[ALL_CASES_SIZE_SUM * 10 + 1]; // 9-bit + '\n' auto *current = all_cases_data; for (uint64_t head = 0; head < 16; ++head) { for (const auto &range : AllCases::fetch()[head]) { @@ -84,3 +85,15 @@ TEST(AllCases, all_cases_data) { auto all_cases_md5 = md5(all_cases_data, ALL_CASES_SIZE_SUM * 10); EXPECT_STREQ(all_cases_md5.c_str(), ALL_CASES_MD5); } + +/// all cases release verify +TEST(AllCases, all_cases_release) { + auto release = AllCases::release(); + auto current = release.begin(); + for (uint64_t head = 0; head < 16; ++head) { + for (const auto &range : AllCases::fetch()[head]) { + EXPECT_EQ(*current, head << 32 | range); + ++current; + } + } +}