aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/int128
diff options
context:
space:
mode:
authordimanne <dimanne@yandex-team.ru>2022-02-10 16:49:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:48 +0300
commit93d66104be406c5b8cdfce7be5546d72d83b547e (patch)
tree5b4284b97105f480aa2b1ffc564e8f8e5b689df9 /library/cpp/int128
parentb3eef5b52437f05851a3e8fb489a68db0132657b (diff)
downloadydb-93d66104be406c5b8cdfce7be5546d72d83b547e.tar.gz
Restoring authorship annotation for <dimanne@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/int128')
-rw-r--r--library/cpp/int128/ut/int128_old_ut.cpp134
1 files changed, 67 insertions, 67 deletions
diff --git a/library/cpp/int128/ut/int128_old_ut.cpp b/library/cpp/int128/ut/int128_old_ut.cpp
index 2c5b9e9610..20ff30943e 100644
--- a/library/cpp/int128/ut/int128_old_ut.cpp
+++ b/library/cpp/int128/ut/int128_old_ut.cpp
@@ -1,10 +1,10 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/int128/int128.h>
-
+
#include "int128_ut_helpers.h"
-class TUInt128Test: public TTestBase {
- UNIT_TEST_SUITE(TUInt128Test);
+class TUInt128Test: public TTestBase {
+ UNIT_TEST_SUITE(TUInt128Test);
UNIT_TEST(Create);
UNIT_TEST(Minus);
UNIT_TEST(Plus);
@@ -16,100 +16,100 @@ class TUInt128Test: public TTestBase {
#if defined(Y_HAVE_INT128)
UNIT_TEST(FromSystemUint128);
#endif
- UNIT_TEST_SUITE_END();
-
-private:
- void Create();
- void Minus();
- void Plus();
- void Shift();
- void Overflow();
- void Underflow();
+ UNIT_TEST_SUITE_END();
+
+private:
+ void Create();
+ void Minus();
+ void Plus();
+ void Shift();
+ void Overflow();
+ void Underflow();
void ToStringTest();
void FromStringTest();
#if defined(Y_HAVE_INT128)
void FromSystemUint128();
#endif
-};
-
-UNIT_TEST_SUITE_REGISTRATION(TUInt128Test);
-
-void TUInt128Test::Create() {
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TUInt128Test);
+
+void TUInt128Test::Create() {
const ui128 n1 = 10;
- UNIT_ASSERT_EQUAL(n1, 10);
-
+ UNIT_ASSERT_EQUAL(n1, 10);
+
const ui128 n2 = n1;
- UNIT_ASSERT_EQUAL(n2, 10);
-
+ UNIT_ASSERT_EQUAL(n2, 10);
+
const ui128 n3(10);
- UNIT_ASSERT_EQUAL(n3, 10);
-}
-void TUInt128Test::Minus() {
+ UNIT_ASSERT_EQUAL(n3, 10);
+}
+void TUInt128Test::Minus() {
const ui128 n2 = 20;
const ui128 n3 = 30;
-
+
ui128 n4 = n3 - n2;
- UNIT_ASSERT_EQUAL(n4, 10);
-
- n4 = n4 - 2;
- UNIT_ASSERT_EQUAL(n4, 8);
-
- n4 -= 2;
- UNIT_ASSERT_EQUAL(n4, 6);
-
- n4 = 10 - n4;
- UNIT_ASSERT_EQUAL(n4, 4);
-}
-void TUInt128Test::Plus() {
+ UNIT_ASSERT_EQUAL(n4, 10);
+
+ n4 = n4 - 2;
+ UNIT_ASSERT_EQUAL(n4, 8);
+
+ n4 -= 2;
+ UNIT_ASSERT_EQUAL(n4, 6);
+
+ n4 = 10 - n4;
+ UNIT_ASSERT_EQUAL(n4, 4);
+}
+void TUInt128Test::Plus() {
const ui128 n2 = 20;
const ui128 n3 = 30;
-
+
ui128 n4 = n3 + n2;
- UNIT_ASSERT_EQUAL(n4, 50);
-
- n4 = n4 + 2;
- UNIT_ASSERT_EQUAL(n4, 52);
-
- n4 += 2;
- UNIT_ASSERT_EQUAL(n4, 54);
-
- n4 = 10 + n4;
- UNIT_ASSERT_EQUAL(n4, 64);
-}
-void TUInt128Test::Shift() {
+ UNIT_ASSERT_EQUAL(n4, 50);
+
+ n4 = n4 + 2;
+ UNIT_ASSERT_EQUAL(n4, 52);
+
+ n4 += 2;
+ UNIT_ASSERT_EQUAL(n4, 54);
+
+ n4 = 10 + n4;
+ UNIT_ASSERT_EQUAL(n4, 64);
+}
+void TUInt128Test::Shift() {
ui128 n = 1;
-
+
const ui128 n4 = n << 4;
UNIT_ASSERT_EQUAL(n4, ui128(0x0, 0x0000000000000010));
- UNIT_ASSERT_EQUAL(n4 >> 4, 1);
-
+ UNIT_ASSERT_EQUAL(n4 >> 4, 1);
+
const ui128 n8 = n << 8;
UNIT_ASSERT_EQUAL(n8, ui128(0x0, 0x0000000000000100));
- UNIT_ASSERT_EQUAL(n8 >> 8, 1);
-
+ UNIT_ASSERT_EQUAL(n8 >> 8, 1);
+
const ui128 n60 = n << 60;
UNIT_ASSERT_EQUAL(n60, ui128(0x0, 0x1000000000000000));
- UNIT_ASSERT_EQUAL(n60 >> 60, 1);
-
+ UNIT_ASSERT_EQUAL(n60 >> 60, 1);
+
const ui128 n64 = n << 64;
UNIT_ASSERT_EQUAL(n64, ui128(0x1, 0x0000000000000000));
- UNIT_ASSERT_EQUAL(n64 >> 64, 1);
-
+ UNIT_ASSERT_EQUAL(n64 >> 64, 1);
+
const ui128 n124 = n << 124;
UNIT_ASSERT_EQUAL(n124, ui128(0x1000000000000000, 0x0000000000000000));
- UNIT_ASSERT_EQUAL(n124 >> 124, 1);
-}
-
-void TUInt128Test::Overflow() {
+ UNIT_ASSERT_EQUAL(n124 >> 124, 1);
+}
+
+void TUInt128Test::Overflow() {
ui128 n = ui128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF);
const ui128 n2 = n + 2;
- UNIT_ASSERT_EQUAL(n2, 1);
-}
-void TUInt128Test::Underflow() {
+ UNIT_ASSERT_EQUAL(n2, 1);
+}
+void TUInt128Test::Underflow() {
ui128 n = 1;
const ui128 n128 = n - 2;
UNIT_ASSERT_EQUAL(n128, ui128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF));
-}
+}
void TUInt128Test::ToStringTest() {
ui128 n(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF);