diff options
author | ermolovd <ermolovd@yandex-team.ru> | 2022-02-10 16:47:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:53 +0300 |
commit | b91bcef7c99a119b0846479ef71bfab4beec72ca (patch) | |
tree | be118d54d12a61bc4812ceb0a266a170a2fa3bc9 /library/cpp/int128 | |
parent | f421873774cf0b71743afbe5f6677861e66601ea (diff) | |
download | ydb-b91bcef7c99a119b0846479ef71bfab4beec72ca.tar.gz |
Restoring authorship annotation for <ermolovd@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/int128')
-rw-r--r-- | library/cpp/int128/int128.cpp | 20 | ||||
-rw-r--r-- | library/cpp/int128/int128.h | 2 | ||||
-rw-r--r-- | library/cpp/int128/ut/int128_ut.cpp | 58 |
3 files changed, 40 insertions, 40 deletions
diff --git a/library/cpp/int128/int128.cpp b/library/cpp/int128/int128.cpp index a28a389fe8..d81204f0b4 100644 --- a/library/cpp/int128/int128.cpp +++ b/library/cpp/int128/int128.cpp @@ -50,13 +50,13 @@ void TSerializer<ui128>::Load(IInputStream* in, ui128& Number) { ::Load(in, Low); Number = ui128(High, Low); } - -IOutputStream& operator<<(IOutputStream& out, const i128& other) -{ - if (other >= 0) { - out << ui128{other}; - } else { - out << '-' << ui128{-other}; - } - return out; -} + +IOutputStream& operator<<(IOutputStream& out, const i128& other) +{ + if (other >= 0) { + out << ui128{other}; + } else { + out << '-' << ui128{-other}; + } + return out; +} diff --git a/library/cpp/int128/int128.h b/library/cpp/int128/int128.h index f1121fc0c6..c015a93af6 100644 --- a/library/cpp/int128/int128.h +++ b/library/cpp/int128/int128.h @@ -204,7 +204,7 @@ public: } constexpr TInteger128& operator^=(const TInteger128 other) noexcept { - return *this = *this ^ other; + return *this = *this ^ other; } constexpr TInteger128& operator|=(const TInteger128 other) noexcept { diff --git a/library/cpp/int128/ut/int128_ut.cpp b/library/cpp/int128/ut/int128_ut.cpp index 7339264017..dbc5634d5e 100644 --- a/library/cpp/int128/ut/int128_ut.cpp +++ b/library/cpp/int128/ut/int128_ut.cpp @@ -51,33 +51,33 @@ Y_UNIT_TEST_SUITE(Uint128Suite) { UNIT_ASSERT(!std::signbit(i128{0})); UNIT_ASSERT(std::signbit(i128{-1})); } - - Y_UNIT_TEST(ToStringTest) { - // int128 - UNIT_ASSERT_VALUES_EQUAL(ToString(i128(0)), "0"); - UNIT_ASSERT_VALUES_EQUAL(ToString(i128(42)), "42"); - UNIT_ASSERT_VALUES_EQUAL(ToString(i128(-142)), "-142"); - UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<i128>::min()), "-170141183460469231731687303715884105728"); - UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<i128>::max()), "170141183460469231731687303715884105727"); - - // Just random number - UNIT_ASSERT_VALUES_EQUAL( - ToString( - - ((i128(8741349088318632894ul) << 64) | i128(1258331728153556511ul)) - ), - "-161249429491168133245752281683002013215"); - - // uint128 - UNIT_ASSERT_VALUES_EQUAL(ToString(ui128(0)), "0"); - UNIT_ASSERT_VALUES_EQUAL(ToString(ui128(42)), "42"); - UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<ui128>::min()), "0"); - UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<ui128>::max()), "340282366920938463463374607431768211455"); - - // Just random number - UNIT_ASSERT_VALUES_EQUAL( - ToString( - ((ui128(12745260439834612983ul) << 64) | ui128(10970669179777569799ul)) - ), - "235108557486403940296800289353599800327"); - } + + Y_UNIT_TEST(ToStringTest) { + // int128 + UNIT_ASSERT_VALUES_EQUAL(ToString(i128(0)), "0"); + UNIT_ASSERT_VALUES_EQUAL(ToString(i128(42)), "42"); + UNIT_ASSERT_VALUES_EQUAL(ToString(i128(-142)), "-142"); + UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<i128>::min()), "-170141183460469231731687303715884105728"); + UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<i128>::max()), "170141183460469231731687303715884105727"); + + // Just random number + UNIT_ASSERT_VALUES_EQUAL( + ToString( + - ((i128(8741349088318632894ul) << 64) | i128(1258331728153556511ul)) + ), + "-161249429491168133245752281683002013215"); + + // uint128 + UNIT_ASSERT_VALUES_EQUAL(ToString(ui128(0)), "0"); + UNIT_ASSERT_VALUES_EQUAL(ToString(ui128(42)), "42"); + UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<ui128>::min()), "0"); + UNIT_ASSERT_VALUES_EQUAL(ToString(std::numeric_limits<ui128>::max()), "340282366920938463463374607431768211455"); + + // Just random number + UNIT_ASSERT_VALUES_EQUAL( + ToString( + ((ui128(12745260439834612983ul) << 64) | ui128(10970669179777569799ul)) + ), + "235108557486403940296800289353599800327"); + } } |