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 | 2a4a975b112fa0fa138abc7457fe67e0e1e7fd02 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/int128 | |
parent | b91bcef7c99a119b0846479ef71bfab4beec72ca (diff) | |
download | ydb-2a4a975b112fa0fa138abc7457fe67e0e1e7fd02.tar.gz |
Restoring authorship annotation for <ermolovd@yandex-team.ru>. Commit 2 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 d81204f0b4..a28a389fe8 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 c015a93af6..f1121fc0c6 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 dbc5634d5e..7339264017 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"); + } } |