aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/int128/ut/i128_comparison_ut.cpp
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:25 +0300
commit344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/int128/ut/i128_comparison_ut.cpp
parent706b83ed7de5a473436620367af31fc0ceecde07 (diff)
downloadydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/int128/ut/i128_comparison_ut.cpp')
-rw-r--r--library/cpp/int128/ut/i128_comparison_ut.cpp286
1 files changed, 143 insertions, 143 deletions
diff --git a/library/cpp/int128/ut/i128_comparison_ut.cpp b/library/cpp/int128/ut/i128_comparison_ut.cpp
index 8e38ac17e2..7b8d508815 100644
--- a/library/cpp/int128/ut/i128_comparison_ut.cpp
+++ b/library/cpp/int128/ut/i128_comparison_ut.cpp
@@ -1,145 +1,145 @@
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <library/cpp/int128/int128.h>
-
-#include <util/generic/cast.h>
-
-Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithPositiveSuite) {
- Y_UNIT_TEST(PositivePositiveGreater) {
- UNIT_ASSERT(i128{1} > i128{0});
- UNIT_ASSERT(i128{2} > i128{1});
- UNIT_ASSERT(i128{42} > i128{0});
- UNIT_ASSERT(i128{42} > i128{1});
- i128 big = i128{1, 0};
- UNIT_ASSERT(big > i128{1});
- UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{0});
- }
-
- Y_UNIT_TEST(PositivePositiveGreaterOrEqual) {
- UNIT_ASSERT(i128{1} >= i128{0});
- UNIT_ASSERT(i128{2} >= i128{1});
- UNIT_ASSERT(i128{42} >= i128{0});
- UNIT_ASSERT(i128{42} >= i128{1});
- i128 big = i128{1, 0};
- UNIT_ASSERT(big >= i128{1});
- UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{0});
-
- UNIT_ASSERT(i128{0} >= i128{0});
- UNIT_ASSERT(i128{1} >= i128{1});
- UNIT_ASSERT(i128{2} >= i128{2});
- UNIT_ASSERT(i128{42} >= i128{42});
- UNIT_ASSERT(big >= big);
- UNIT_ASSERT(std::numeric_limits<i128>::max() >= std::numeric_limits<i128>::max());
- }
-
- Y_UNIT_TEST(PositivePositiveLess) {
- UNIT_ASSERT(i128{0} < i128{1});
- UNIT_ASSERT(i128{1} < i128{2});
- UNIT_ASSERT(i128{0} < i128{42});
- UNIT_ASSERT(i128{1} < i128{42});
- i128 big = i128{1, 0};
- UNIT_ASSERT(i128{1} < big);
- UNIT_ASSERT(i128{0} < std::numeric_limits<i128>::max());
- }
-
- Y_UNIT_TEST(PositivePositiveLessOrEqual) {
- UNIT_ASSERT(i128{0} <= i128{1});
- UNIT_ASSERT(i128{1} <= i128{2});
- UNIT_ASSERT(i128{0} <= i128{42});
- UNIT_ASSERT(i128{1} <= i128{42});
- i128 big = i128{1, 0};
- UNIT_ASSERT(i128{1} <= big);
- UNIT_ASSERT(i128{0} <= std::numeric_limits<i128>::max());
-
- UNIT_ASSERT(i128{0} <= i128{0});
- UNIT_ASSERT(i128{1} <= i128{1});
- UNIT_ASSERT(i128{2} <= i128{2});
- UNIT_ASSERT(i128{42} <= i128{42});
- UNIT_ASSERT(big <= big);
- UNIT_ASSERT(std::numeric_limits<i128>::max() <= std::numeric_limits<i128>::max());
- }
-}
-
-Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithNegativeSuite) {
- Y_UNIT_TEST(PositiveNegativeGreater) {
- UNIT_ASSERT(i128{0} > i128{-1});
- UNIT_ASSERT(i128{2} > i128{-1});
- UNIT_ASSERT(i128{0} > i128{-42});
- UNIT_ASSERT(i128{42} > i128{-1});
- i128 big = i128{1, 0};
- UNIT_ASSERT(big > i128{-1});
- UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{-1});
- }
-
- Y_UNIT_TEST(PositiveNegativeGreaterOrEqual) {
- UNIT_ASSERT(i128{0} >= i128{-1});
- UNIT_ASSERT(i128{2} >= i128{-1});
- UNIT_ASSERT(i128{0} >= i128{-42});
- UNIT_ASSERT(i128{42} >= i128{-1});
- i128 big = i128{1, 0};
- UNIT_ASSERT(big >= i128{-1});
- UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{-1});
- }
-
- Y_UNIT_TEST(NegativePositiveLess) {
- UNIT_ASSERT(i128{-1} < i128{0});
- UNIT_ASSERT(i128{-1} < i128{2});
- UNIT_ASSERT(i128{-42} < i128{0});
- UNIT_ASSERT(i128{-1} < i128{42});
- i128 big = i128{1, 0};
- UNIT_ASSERT(i128{-1} < big);
- UNIT_ASSERT(i128{-1} < std::numeric_limits<i128>::max());
- }
-
- Y_UNIT_TEST(NegativePositiveLessOrEqual) {
- UNIT_ASSERT(i128{-1} <= i128{0});
- UNIT_ASSERT(i128{-1} <= i128{2});
- UNIT_ASSERT(i128{-42} <= i128{0});
- UNIT_ASSERT(i128{-1} <= i128{42});
- i128 big = i128{1, 0};
- UNIT_ASSERT(i128{-1} <= big);
- UNIT_ASSERT(i128{-1} <= std::numeric_limits<i128>::max());
- }
-}
-
-Y_UNIT_TEST_SUITE(I128ComparisonNegativeWithNegativeSuite) {
- Y_UNIT_TEST(NegativeNegativeGreater) {
- UNIT_ASSERT(i128{-1} > i128{-2});
- UNIT_ASSERT(i128{-2} > i128{-3});
- UNIT_ASSERT(i128{-1} > i128{-42});
- UNIT_ASSERT(i128{-42} > i128{-142});
- i128 big = -i128{1, 0};
- UNIT_ASSERT(i128{-1} > big);
- UNIT_ASSERT(i128{-1} > std::numeric_limits<i128>::min());
- }
-
- Y_UNIT_TEST(NegativeNegativeGreaterOrEqual) {
- UNIT_ASSERT(i128{-1} >= i128{-2});
- UNIT_ASSERT(i128{-2} >= i128{-3});
- UNIT_ASSERT(i128{-1} >= i128{-42});
- UNIT_ASSERT(i128{-42} >= i128{-142});
- i128 big = -i128{1, 0};
- UNIT_ASSERT(i128{-1} >= big);
- UNIT_ASSERT(i128{-1} >= std::numeric_limits<i128>::min());
- }
-
- Y_UNIT_TEST(NegativeNegativeLess) {
- UNIT_ASSERT(i128{-2} < i128{-1});
- UNIT_ASSERT(i128{-3} < i128{-2});
- UNIT_ASSERT(i128{-42} < i128{-1});
- UNIT_ASSERT(i128{-142} < i128{42});
- i128 big = -i128{1, 0};
- UNIT_ASSERT(big < i128{-1});
- UNIT_ASSERT(std::numeric_limits<i128>::min() < i128{-1});
- }
-
- Y_UNIT_TEST(NegativeNegativeLessOrEqual) {
- UNIT_ASSERT(i128{-2} <= i128{-1});
- UNIT_ASSERT(i128{-3} <= i128{-2});
- UNIT_ASSERT(i128{-42} <= i128{-1});
- UNIT_ASSERT(i128{-142} <= i128{42});
- i128 big = -i128{1, 0};
- UNIT_ASSERT(big <= i128{-1});
- UNIT_ASSERT(std::numeric_limits<i128>::min() <= i128{-1});
- }
-}
+
+#include <util/generic/cast.h>
+
+Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithPositiveSuite) {
+ Y_UNIT_TEST(PositivePositiveGreater) {
+ UNIT_ASSERT(i128{1} > i128{0});
+ UNIT_ASSERT(i128{2} > i128{1});
+ UNIT_ASSERT(i128{42} > i128{0});
+ UNIT_ASSERT(i128{42} > i128{1});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(big > i128{1});
+ UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{0});
+ }
+
+ Y_UNIT_TEST(PositivePositiveGreaterOrEqual) {
+ UNIT_ASSERT(i128{1} >= i128{0});
+ UNIT_ASSERT(i128{2} >= i128{1});
+ UNIT_ASSERT(i128{42} >= i128{0});
+ UNIT_ASSERT(i128{42} >= i128{1});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(big >= i128{1});
+ UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{0});
+
+ UNIT_ASSERT(i128{0} >= i128{0});
+ UNIT_ASSERT(i128{1} >= i128{1});
+ UNIT_ASSERT(i128{2} >= i128{2});
+ UNIT_ASSERT(i128{42} >= i128{42});
+ UNIT_ASSERT(big >= big);
+ UNIT_ASSERT(std::numeric_limits<i128>::max() >= std::numeric_limits<i128>::max());
+ }
+
+ Y_UNIT_TEST(PositivePositiveLess) {
+ UNIT_ASSERT(i128{0} < i128{1});
+ UNIT_ASSERT(i128{1} < i128{2});
+ UNIT_ASSERT(i128{0} < i128{42});
+ UNIT_ASSERT(i128{1} < i128{42});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(i128{1} < big);
+ UNIT_ASSERT(i128{0} < std::numeric_limits<i128>::max());
+ }
+
+ Y_UNIT_TEST(PositivePositiveLessOrEqual) {
+ UNIT_ASSERT(i128{0} <= i128{1});
+ UNIT_ASSERT(i128{1} <= i128{2});
+ UNIT_ASSERT(i128{0} <= i128{42});
+ UNIT_ASSERT(i128{1} <= i128{42});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(i128{1} <= big);
+ UNIT_ASSERT(i128{0} <= std::numeric_limits<i128>::max());
+
+ UNIT_ASSERT(i128{0} <= i128{0});
+ UNIT_ASSERT(i128{1} <= i128{1});
+ UNIT_ASSERT(i128{2} <= i128{2});
+ UNIT_ASSERT(i128{42} <= i128{42});
+ UNIT_ASSERT(big <= big);
+ UNIT_ASSERT(std::numeric_limits<i128>::max() <= std::numeric_limits<i128>::max());
+ }
+}
+
+Y_UNIT_TEST_SUITE(I128ComparisonPositiveWithNegativeSuite) {
+ Y_UNIT_TEST(PositiveNegativeGreater) {
+ UNIT_ASSERT(i128{0} > i128{-1});
+ UNIT_ASSERT(i128{2} > i128{-1});
+ UNIT_ASSERT(i128{0} > i128{-42});
+ UNIT_ASSERT(i128{42} > i128{-1});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(big > i128{-1});
+ UNIT_ASSERT(std::numeric_limits<i128>::max() > i128{-1});
+ }
+
+ Y_UNIT_TEST(PositiveNegativeGreaterOrEqual) {
+ UNIT_ASSERT(i128{0} >= i128{-1});
+ UNIT_ASSERT(i128{2} >= i128{-1});
+ UNIT_ASSERT(i128{0} >= i128{-42});
+ UNIT_ASSERT(i128{42} >= i128{-1});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(big >= i128{-1});
+ UNIT_ASSERT(std::numeric_limits<i128>::max() >= i128{-1});
+ }
+
+ Y_UNIT_TEST(NegativePositiveLess) {
+ UNIT_ASSERT(i128{-1} < i128{0});
+ UNIT_ASSERT(i128{-1} < i128{2});
+ UNIT_ASSERT(i128{-42} < i128{0});
+ UNIT_ASSERT(i128{-1} < i128{42});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(i128{-1} < big);
+ UNIT_ASSERT(i128{-1} < std::numeric_limits<i128>::max());
+ }
+
+ Y_UNIT_TEST(NegativePositiveLessOrEqual) {
+ UNIT_ASSERT(i128{-1} <= i128{0});
+ UNIT_ASSERT(i128{-1} <= i128{2});
+ UNIT_ASSERT(i128{-42} <= i128{0});
+ UNIT_ASSERT(i128{-1} <= i128{42});
+ i128 big = i128{1, 0};
+ UNIT_ASSERT(i128{-1} <= big);
+ UNIT_ASSERT(i128{-1} <= std::numeric_limits<i128>::max());
+ }
+}
+
+Y_UNIT_TEST_SUITE(I128ComparisonNegativeWithNegativeSuite) {
+ Y_UNIT_TEST(NegativeNegativeGreater) {
+ UNIT_ASSERT(i128{-1} > i128{-2});
+ UNIT_ASSERT(i128{-2} > i128{-3});
+ UNIT_ASSERT(i128{-1} > i128{-42});
+ UNIT_ASSERT(i128{-42} > i128{-142});
+ i128 big = -i128{1, 0};
+ UNIT_ASSERT(i128{-1} > big);
+ UNIT_ASSERT(i128{-1} > std::numeric_limits<i128>::min());
+ }
+
+ Y_UNIT_TEST(NegativeNegativeGreaterOrEqual) {
+ UNIT_ASSERT(i128{-1} >= i128{-2});
+ UNIT_ASSERT(i128{-2} >= i128{-3});
+ UNIT_ASSERT(i128{-1} >= i128{-42});
+ UNIT_ASSERT(i128{-42} >= i128{-142});
+ i128 big = -i128{1, 0};
+ UNIT_ASSERT(i128{-1} >= big);
+ UNIT_ASSERT(i128{-1} >= std::numeric_limits<i128>::min());
+ }
+
+ Y_UNIT_TEST(NegativeNegativeLess) {
+ UNIT_ASSERT(i128{-2} < i128{-1});
+ UNIT_ASSERT(i128{-3} < i128{-2});
+ UNIT_ASSERT(i128{-42} < i128{-1});
+ UNIT_ASSERT(i128{-142} < i128{42});
+ i128 big = -i128{1, 0};
+ UNIT_ASSERT(big < i128{-1});
+ UNIT_ASSERT(std::numeric_limits<i128>::min() < i128{-1});
+ }
+
+ Y_UNIT_TEST(NegativeNegativeLessOrEqual) {
+ UNIT_ASSERT(i128{-2} <= i128{-1});
+ UNIT_ASSERT(i128{-3} <= i128{-2});
+ UNIT_ASSERT(i128{-42} <= i128{-1});
+ UNIT_ASSERT(i128{-142} <= i128{42});
+ i128 big = -i128{1, 0};
+ UNIT_ASSERT(big <= i128{-1});
+ UNIT_ASSERT(std::numeric_limits<i128>::min() <= i128{-1});
+ }
+}