Browse Source

test: add vertical mirror global test

master
Dnomd343 2 years ago
parent
commit
7a282aa628
  1. 45
      test/codec/raw_code.cc

45
test/codec/raw_code.cc

@ -77,6 +77,26 @@ TEST(RawCode, initializate) {
EXPECT_EQ(RawCode::from_common_code(common_code.to_string()).unwrap(), TEST_CODE); // r-value
}
TEST(RawCode, vertical_mirror) {
auto raw_code_1 = RawCode::unsafe_create(0x0'FC0'480'6DB'FC0'480); // invalid layout only for test
auto raw_code_2 = RawCode::from_common_code(0x4FEA13400);
auto raw_code_2_ = RawCode::from_common_code(0x8346AFC00);
EXPECT_EQ(raw_code_1.is_vertical_mirror(), true);
EXPECT_EQ(raw_code_1.to_vertical_mirror(), raw_code_1);
EXPECT_EQ(raw_code_1.is_vertical_mirror(raw_code_1), true); // l-value
EXPECT_EQ(raw_code_1.is_vertical_mirror(raw_code_2), false); // l-value
EXPECT_EQ(raw_code_1.is_vertical_mirror(static_cast<RawCode&&>(raw_code_1)), true); // r-value
EXPECT_EQ(raw_code_1.is_vertical_mirror(static_cast<RawCode&&>(raw_code_2)), false); // r-value
EXPECT_EQ(raw_code_2.is_vertical_mirror(), false);
EXPECT_EQ(raw_code_2.to_vertical_mirror(), raw_code_2_);
EXPECT_EQ(raw_code_2.is_vertical_mirror(raw_code_1), false); // l-value
EXPECT_EQ(raw_code_2.is_vertical_mirror(raw_code_2_), true); // l-value
EXPECT_EQ(raw_code_2.is_vertical_mirror(static_cast<RawCode&&>(raw_code_1)), false); // r-value
EXPECT_EQ(raw_code_2.is_vertical_mirror(static_cast<RawCode&&>(raw_code_2_)), true); // r-value
}
TEST(RawCode, horizontal_mirror) {
auto raw_code_1 = RawCode::from_common_code(0x1A9BF0C00);
auto raw_code_2 = RawCode::from_common_code(0x4FEA13400);
@ -97,6 +117,31 @@ TEST(RawCode, horizontal_mirror) {
EXPECT_EQ(raw_code_2.is_horizontal_mirror(static_cast<RawCode&&>(raw_code_2_)), true); // r-value
}
TEST(RawCode, vertical_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_vertical_mirror();
/// verify vertical mirror
EXPECT_EQ(raw_code_mirror.valid(), true);
EXPECT_EQ(raw_code_mirror.to_common_code().to_raw_code(), raw_code_mirror);
EXPECT_EQ(raw_code.is_vertical_mirror(), false);
EXPECT_NE(raw_code, raw_code_mirror);
EXPECT_EQ(raw_code_mirror.to_vertical_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();
}
}
TEST(RawCode, horizontal_mirror_global) {
std::thread threads[16];
auto test = [](uint64_t head) {

Loading…
Cancel
Save