|
|
@ -70,3 +70,51 @@ TEST(RawCode, initializate) { |
|
|
|
EXPECT_EQ(RawCode::from_common_code(common_code_string).unwrap(), TEST_CODE); // l-value
|
|
|
|
EXPECT_EQ(RawCode::from_common_code(common_code.to_string()).unwrap(), TEST_CODE); // r-value
|
|
|
|
} |
|
|
|
|
|
|
|
TEST(RawCode, horizontal_mirror) { |
|
|
|
auto raw_code_1 = RawCode::from_common_code(0x1A9BF0C00); |
|
|
|
auto raw_code_2 = RawCode::from_common_code(0x4FEA13400); |
|
|
|
auto raw_code_2_ = RawCode::from_common_code(0x6BFA47000); |
|
|
|
|
|
|
|
EXPECT_EQ(raw_code_1.is_horizontal_mirror(), true); |
|
|
|
EXPECT_EQ(raw_code_1.to_horizontal_mirror(), raw_code_1); |
|
|
|
EXPECT_EQ(raw_code_1.is_horizontal_mirror(raw_code_1), true); // l-value
|
|
|
|
EXPECT_EQ(raw_code_1.is_horizontal_mirror(raw_code_2), false); // l-value
|
|
|
|
EXPECT_EQ(raw_code_1.is_horizontal_mirror(static_cast<RawCode&&>(raw_code_1)), true); // r-value
|
|
|
|
EXPECT_EQ(raw_code_1.is_horizontal_mirror(static_cast<RawCode&&>(raw_code_2)), false); // r-value
|
|
|
|
|
|
|
|
EXPECT_EQ(raw_code_2.is_horizontal_mirror(), false); |
|
|
|
EXPECT_EQ(raw_code_2.to_horizontal_mirror(), raw_code_2_); |
|
|
|
EXPECT_EQ(raw_code_2.is_horizontal_mirror(raw_code_1), false); // l-value
|
|
|
|
EXPECT_EQ(raw_code_2.is_horizontal_mirror(raw_code_2_), true); // l-value
|
|
|
|
EXPECT_EQ(raw_code_2.is_horizontal_mirror(static_cast<RawCode&&>(raw_code_1)), false); // r-value
|
|
|
|
EXPECT_EQ(raw_code_2.is_horizontal_mirror(static_cast<RawCode&&>(raw_code_2_)), true); // r-value
|
|
|
|
} |
|
|
|
|
|
|
|
TEST(RawCode, horizontal_mirror_global) { |
|
|
|
std::thread threads[16]; |
|
|
|
auto test = [](uint64_t head) { |
|
|
|
for (const auto &range : AllCases::fetch()[head]) { |
|
|
|
/// generate code and mirror layout
|
|
|
|
auto common_code = CommonCode::unsafe_create(head << 32 | range); |
|
|
|
auto raw_code = common_code.to_raw_code(); |
|
|
|
auto raw_code_mirror = raw_code.to_horizontal_mirror(); |
|
|
|
|
|
|
|
/// verify horizontal mirror
|
|
|
|
EXPECT_EQ(raw_code_mirror.valid(), true); |
|
|
|
EXPECT_EQ(raw_code_mirror.to_common_code().to_raw_code(), raw_code_mirror); |
|
|
|
if (raw_code.is_horizontal_mirror()) { |
|
|
|
EXPECT_EQ(raw_code, raw_code_mirror); |
|
|
|
} else { |
|
|
|
EXPECT_NE(raw_code, raw_code_mirror); |
|
|
|
} |
|
|
|
EXPECT_EQ(raw_code_mirror.to_horizontal_mirror(), raw_code); |
|
|
|
} |
|
|
|
}; |
|
|
|
for (uint64_t head = 0; head < 16; ++head) { // split into 16 threads
|
|
|
|
threads[head] = std::thread(test, head); |
|
|
|
} |
|
|
|
for (auto &t : threads) { |
|
|
|
t.join(); |
|
|
|
} |
|
|
|
} |
|
|
|