From cd673ae636f9fdf0c03036793d1376bc1f3eec70 Mon Sep 17 00:00:00 2001 From: Alexander Lvov Date: Mon, 21 Oct 2024 12:49:22 +0300 Subject: [PATCH] Small refactoring. --- test/operations/initialization/signed.cpp | 50 +++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/test/operations/initialization/signed.cpp b/test/operations/initialization/signed.cpp index 3bd48bf..71a069e 100755 --- a/test/operations/initialization/signed.cpp +++ b/test/operations/initialization/signed.cpp @@ -26,24 +26,35 @@ TEST(Signed_Initialization, Basic) { } { using namespace std::string_literals; using namespace std::string_view_literals; - Aesi512 d0 = "489133282872437279"s, d1 = "63018038201"sv, d2 = "-489133282872437279"s, d3 = "-63018038201"sv; - EXPECT_EQ(d0, 489133282872437279); EXPECT_EQ(d1, 63018038201); EXPECT_EQ(d2, -489133282872437279); EXPECT_EQ(d3, -63018038201); + Aesi512 d0 = "489133282872437279"s; EXPECT_EQ(d0, 489133282872437279); + d0 = "63018038201"sv; EXPECT_EQ(d0, 63018038201); + d0 = "-489133282872437279"s; EXPECT_EQ(d0, -489133282872437279); + d0 = "-63018038201"sv; EXPECT_EQ(d0, -63018038201); Aesi512 b0 = "0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279); Aesi512 b1 = "0b111010101100001010101111001110111001"sv; EXPECT_EQ(b1, 63018038201); Aesi512 b2 = "-0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b2, -489133282872437279); Aesi512 b3 = "-0b111010101100001010101111001110111001"sv; EXPECT_EQ(b3, -63018038201); - Aesi512 o0 = "0o106274176273174613"s, o1 = "0o642054234601645202742"sv, o2 = "-0o106274176273174613"s, o3 = "-0o642054234601645202742"sv; - EXPECT_EQ(o0, 2475842268363147); EXPECT_EQ(o1, 7531577461358003682); EXPECT_EQ(o2, -2475842268363147); EXPECT_EQ(o3, -7531577461358003682); + Aesi512 o0 = "0o106274176273174613"s; EXPECT_EQ(o0, 2475842268363147); + o0 = "0o642054234601645202742"sv; EXPECT_EQ(o0, 7531577461358003682); + o0 = "-0o106274176273174613"s; EXPECT_EQ(o0, -2475842268363147); + o0 = "-0o642054234601645202742"sv; EXPECT_EQ(o0, -7531577461358003682); - Aesi512 h0 = "0x688589CC0E9505E2"s, h1 = "0x3C9D4B9CB52FE"sv, h2 = "-0x688589CC0E9505E2"s, h3 = "-0x3C9D4B9CB52FE"sv; - EXPECT_EQ(h0, 7531577461358003682); EXPECT_EQ(h1, 1066340417491710); EXPECT_EQ(h2, -7531577461358003682); EXPECT_EQ(h3, -1066340417491710); - Aesi512 h4 = "0x688589cc0e9505e2"s, h5 = "0x3c9d4b9cb52fe"sv, h6 = "-0x688589cc0e9505e2"s, h7 = "-0x3c9d4b9cb52fe"sv; - EXPECT_EQ(h4, 7531577461358003682); EXPECT_EQ(h5, 1066340417491710); EXPECT_EQ(h6, -7531577461358003682); EXPECT_EQ(h7, -1066340417491710); + Aesi512 h0 = "0x688589CC0E9505E2"s; EXPECT_EQ(h0, 7531577461358003682); + h0 = "0x3C9D4B9CB52FE"sv; EXPECT_EQ(h0, 1066340417491710); + h0 = "-0x688589CC0E9505E2"s; EXPECT_EQ(h0, -7531577461358003682); + h0 = "-0x3C9D4B9CB52FE"sv; EXPECT_EQ(h0, -1066340417491710); - d0 = L"489133282872437279"s, d1 = L"63018038201"sv, d2 = L"-489133282872437279"s, d3 = L"-63018038201"sv; - EXPECT_EQ(d0, 489133282872437279); EXPECT_EQ(d1, 63018038201); EXPECT_EQ(d2, -489133282872437279); EXPECT_EQ(d3, -63018038201); + Aesi512 h4 = "0x688589cc0e9505e2"s; EXPECT_EQ(h4, 7531577461358003682); + h4 = "0x3c9d4b9cb52fe"sv; EXPECT_EQ(h4, 1066340417491710); + h4 = "-0x688589cc0e9505e2"s; EXPECT_EQ(h4, -7531577461358003682); + h4 = "-0x3c9d4b9cb52fe"sv; EXPECT_EQ(h4, -1066340417491710); + + d0 = L"489133282872437279"s; EXPECT_EQ(d0, 489133282872437279); + d0 = L"63018038201"sv; EXPECT_EQ(d0, 63018038201); + d0 = L"-489133282872437279"s; EXPECT_EQ(d0, -489133282872437279); + d0 = L"-63018038201"sv; EXPECT_EQ(d0, -63018038201); b0 = L"0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279); b1 = L"0b111010101100001010101111001110111001"sv; EXPECT_EQ(b1, 63018038201); @@ -69,13 +80,20 @@ TEST(Signed_Initialization, Basic) { b0 = L"-----------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, -489133282872437279LL); b0 = L"------------------0b11011001001110000000010000100010101011011101010101000011111"s; EXPECT_EQ(b0, 489133282872437279LL); - o0 = L"0o106274176273174613"s, o1 = L"0o642054234601645202742"sv, o2 = L"-0o106274176273174613"s, o3 = L"-0o642054234601645202742"sv; - EXPECT_EQ(o0, 2475842268363147); EXPECT_EQ(o1, 7531577461358003682); EXPECT_EQ(o2, -2475842268363147); EXPECT_EQ(o3, -7531577461358003682); + o0 = L"0o106274176273174613"s; EXPECT_EQ(o0, 2475842268363147); + o0 = L"0o642054234601645202742"sv; EXPECT_EQ(o0, 7531577461358003682); + o0 = L"-0o106274176273174613"s; EXPECT_EQ(o0, -2475842268363147); + o0 = L"-0o642054234601645202742"sv; EXPECT_EQ(o0, -7531577461358003682); + + h0 = L"0x688589CC0E9505E2"s; EXPECT_EQ(h0, 7531577461358003682); + h0 = L"0x3C9D4B9CB52FE"sv; EXPECT_EQ(h0, 1066340417491710); + h0 = L"-0x688589CC0E9505E2"s; EXPECT_EQ(h0, -7531577461358003682); + h0 = L"-0x3C9D4B9CB52FE"sv; EXPECT_EQ(h0, -1066340417491710); - h0 = L"0x688589CC0E9505E2"s, h1 = L"0x3C9D4B9CB52FE"sv, h2 = L"-0x688589CC0E9505E2"s, h3 = L"-0x3C9D4B9CB52FE"sv; - EXPECT_EQ(h0, 7531577461358003682); EXPECT_EQ(h1, 1066340417491710); EXPECT_EQ(h2, -7531577461358003682); EXPECT_EQ(h3, -1066340417491710); - h4 = L"0x688589cc0e9505e2"s, h5 = L"0x3c9d4b9cb52fe"sv, h6 = L"-0x688589cc0e9505e2"s, h7 = L"-0x3c9d4b9cb52fe"sv; - EXPECT_EQ(h4, 7531577461358003682); EXPECT_EQ(h5, 1066340417491710); EXPECT_EQ(h6, -7531577461358003682); EXPECT_EQ(h7, -1066340417491710); + h4 = L"0x688589cc0e9505e2"s; EXPECT_EQ(h4, 7531577461358003682); + h4 = L"0x3c9d4b9cb52fe"sv; EXPECT_EQ(h4, 1066340417491710); + h4 = L"-0x688589cc0e9505e2"s; EXPECT_EQ(h4, -7531577461358003682); + h4 = L"-0x3c9d4b9cb52fe"sv; EXPECT_EQ(h4, -1066340417491710); } }