diff options
author | babenko <babenko@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
commit | f31097c96270919a1f49360bdaaa69ea4f3fefab (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/coding/unittests/zig_zag_ut.cpp | |
parent | cec37806d8847aa3db53bafc9e251d4aaf325c12 (diff) | |
download | ydb-f31097c96270919a1f49360bdaaa69ea4f3fefab.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/coding/unittests/zig_zag_ut.cpp')
-rw-r--r-- | library/cpp/yt/coding/unittests/zig_zag_ut.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/library/cpp/yt/coding/unittests/zig_zag_ut.cpp b/library/cpp/yt/coding/unittests/zig_zag_ut.cpp index ba092df287..fae4e63064 100644 --- a/library/cpp/yt/coding/unittests/zig_zag_ut.cpp +++ b/library/cpp/yt/coding/unittests/zig_zag_ut.cpp @@ -1,57 +1,57 @@ -#include <library/cpp/testing/gtest/gtest.h> - -#include <library/cpp/yt/coding/zig_zag.h> - -namespace NYT { -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -TEST(TZigZagTest, Encode32) -{ - EXPECT_EQ(0u, ZigZagEncode32( 0)); - EXPECT_EQ(1u, ZigZagEncode32(-1)); - EXPECT_EQ(2u, ZigZagEncode32( 1)); - EXPECT_EQ(3u, ZigZagEncode32(-2)); - // ... - EXPECT_EQ(std::numeric_limits<ui32>::max() - 1, ZigZagEncode32(std::numeric_limits<i32>::max())); - EXPECT_EQ(std::numeric_limits<ui32>::max(), ZigZagEncode32(std::numeric_limits<i32>::min())); -} - -TEST(TZigZagTest, Decode32) -{ - EXPECT_EQ( 0, ZigZagDecode32(0)); - EXPECT_EQ(-1, ZigZagDecode32(1)); - EXPECT_EQ( 1, ZigZagDecode32(2)); - EXPECT_EQ(-2, ZigZagDecode32(3)); - // ... - EXPECT_EQ(std::numeric_limits<i32>::max(), ZigZagDecode32(std::numeric_limits<ui32>::max() - 1)); - EXPECT_EQ(std::numeric_limits<i32>::min(), ZigZagDecode32(std::numeric_limits<ui32>::max())); -} - -TEST(TZigZagTest, Encode64) -{ - EXPECT_EQ(0ull, ZigZagEncode64( 0)); - EXPECT_EQ(1ull, ZigZagEncode64(-1)); - EXPECT_EQ(2ull, ZigZagEncode64( 1)); - EXPECT_EQ(3ull, ZigZagEncode64(-2)); - // ... - EXPECT_EQ(std::numeric_limits<ui64>::max() - 1, ZigZagEncode64(std::numeric_limits<i64>::max())); - EXPECT_EQ(std::numeric_limits<ui64>::max(), ZigZagEncode64(std::numeric_limits<i64>::min())); -} - -TEST(TZigZagTest, Decode64) -{ - EXPECT_EQ(ZigZagDecode64(0), 0ll); - EXPECT_EQ(ZigZagDecode64(1), -1ll); - EXPECT_EQ(ZigZagDecode64(2), 1ll); - EXPECT_EQ(ZigZagDecode64(3), -2ll); - // ... - EXPECT_EQ(std::numeric_limits<i64>::max(), ZigZagDecode64(std::numeric_limits<ui64>::max() - 1)); - EXPECT_EQ(std::numeric_limits<i64>::min(), ZigZagDecode64(std::numeric_limits<ui64>::max())); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace -} // namespace NYT +#include <library/cpp/testing/gtest/gtest.h> + +#include <library/cpp/yt/coding/zig_zag.h> + +namespace NYT { +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +TEST(TZigZagTest, Encode32) +{ + EXPECT_EQ(0u, ZigZagEncode32( 0)); + EXPECT_EQ(1u, ZigZagEncode32(-1)); + EXPECT_EQ(2u, ZigZagEncode32( 1)); + EXPECT_EQ(3u, ZigZagEncode32(-2)); + // ... + EXPECT_EQ(std::numeric_limits<ui32>::max() - 1, ZigZagEncode32(std::numeric_limits<i32>::max())); + EXPECT_EQ(std::numeric_limits<ui32>::max(), ZigZagEncode32(std::numeric_limits<i32>::min())); +} + +TEST(TZigZagTest, Decode32) +{ + EXPECT_EQ( 0, ZigZagDecode32(0)); + EXPECT_EQ(-1, ZigZagDecode32(1)); + EXPECT_EQ( 1, ZigZagDecode32(2)); + EXPECT_EQ(-2, ZigZagDecode32(3)); + // ... + EXPECT_EQ(std::numeric_limits<i32>::max(), ZigZagDecode32(std::numeric_limits<ui32>::max() - 1)); + EXPECT_EQ(std::numeric_limits<i32>::min(), ZigZagDecode32(std::numeric_limits<ui32>::max())); +} + +TEST(TZigZagTest, Encode64) +{ + EXPECT_EQ(0ull, ZigZagEncode64( 0)); + EXPECT_EQ(1ull, ZigZagEncode64(-1)); + EXPECT_EQ(2ull, ZigZagEncode64( 1)); + EXPECT_EQ(3ull, ZigZagEncode64(-2)); + // ... + EXPECT_EQ(std::numeric_limits<ui64>::max() - 1, ZigZagEncode64(std::numeric_limits<i64>::max())); + EXPECT_EQ(std::numeric_limits<ui64>::max(), ZigZagEncode64(std::numeric_limits<i64>::min())); +} + +TEST(TZigZagTest, Decode64) +{ + EXPECT_EQ(ZigZagDecode64(0), 0ll); + EXPECT_EQ(ZigZagDecode64(1), -1ll); + EXPECT_EQ(ZigZagDecode64(2), 1ll); + EXPECT_EQ(ZigZagDecode64(3), -2ll); + // ... + EXPECT_EQ(std::numeric_limits<i64>::max(), ZigZagDecode64(std::numeric_limits<ui64>::max() - 1)); + EXPECT_EQ(std::numeric_limits<i64>::min(), ZigZagDecode64(std::numeric_limits<ui64>::max())); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace +} // namespace NYT |