aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/ymath_ut.cpp
diff options
context:
space:
mode:
authorakhropov <akhropov@yandex-team.ru>2022-02-10 16:46:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:32 +0300
commit00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (patch)
treecb7a9f4a92c0d4cc5a86eeed49ad71e810953c1f /util/generic/ymath_ut.cpp
parent83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (diff)
downloadydb-00afc96e9c0298054b7386fa7fb9e3cc3d67b974.tar.gz
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/ymath_ut.cpp')
-rw-r--r--util/generic/ymath_ut.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index 29190b55eb..15514e4bb3 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -34,7 +34,7 @@ class TMathTest: public TTestBase {
UNIT_TEST(TestAbs);
UNIT_TEST(TestPower);
UNIT_TEST(TestSigmoid);
- UNIT_TEST(TestCeilDiv);
+ UNIT_TEST(TestCeilDiv);
UNIT_TEST_SUITE_END();
private:
@@ -45,7 +45,7 @@ private:
void TestAbs();
void TestPower();
void TestSigmoid();
- void TestCeilDiv();
+ void TestCeilDiv();
inline void TestIsValidFloat() {
UNIT_ASSERT(IsValidFloat(-Max<double>() / 2.));
@@ -191,30 +191,30 @@ void TMathTest::TestSigmoid() {
UNIT_ASSERT_EQUAL(Sigmoid(-5000.), 0.0);
UNIT_ASSERT_EQUAL(Sigmoid(5000.), 1.0);
}
-
-void TMathTest::TestCeilDiv() {
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(2, 3), 1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(3, 3), 1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui32>(12, 2), 6);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui64>(10, 3), 4);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui64>(0, 10), 0);
-
- // negative numbers
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(0, -10), 0);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-1, 2), 0);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-1, -2), 1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(10, -5), -2);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-3, -4), 1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-6, -4), 2);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-6, 4), -1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-13, 4), -3);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-14, -4), 4);
-
- // check values close to overflow
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(255, 10), 26);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui32>(std::numeric_limits<ui32>::max() - 3, std::numeric_limits<ui32>::max()), 1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i32>(std::numeric_limits<i32>::max() - 3, std::numeric_limits<i32>::max()), 1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i32>(std::numeric_limits<i32>::min(), std::numeric_limits<i32>::max()), -1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i8>(std::numeric_limits<i8>::max(), std::numeric_limits<i8>::min() + 1), -1);
- UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i64>(std::numeric_limits<i64>::max() - 2, -(std::numeric_limits<i64>::min() + 1)), 1);
-}
+
+void TMathTest::TestCeilDiv() {
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(2, 3), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(3, 3), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui32>(12, 2), 6);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui64>(10, 3), 4);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui64>(0, 10), 0);
+
+ // negative numbers
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(0, -10), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-1, 2), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-1, -2), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(10, -5), -2);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-3, -4), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-6, -4), 2);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-6, 4), -1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-13, 4), -3);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv(-14, -4), 4);
+
+ // check values close to overflow
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(255, 10), 26);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui32>(std::numeric_limits<ui32>::max() - 3, std::numeric_limits<ui32>::max()), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i32>(std::numeric_limits<i32>::max() - 3, std::numeric_limits<i32>::max()), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i32>(std::numeric_limits<i32>::min(), std::numeric_limits<i32>::max()), -1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i8>(std::numeric_limits<i8>::max(), std::numeric_limits<i8>::min() + 1), -1);
+ UNIT_ASSERT_VALUES_EQUAL(CeilDiv<i64>(std::numeric_limits<i64>::max() - 2, -(std::numeric_limits<i64>::min() + 1)), 1);
+}