aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/overloaded_ut.cpp
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:39 +0300
commita6a92afe03e02795227d2641b49819b687f088f8 (patch)
treef6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /util/generic/overloaded_ut.cpp
parentc6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff)
downloadydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic/overloaded_ut.cpp')
-rw-r--r--util/generic/overloaded_ut.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/util/generic/overloaded_ut.cpp b/util/generic/overloaded_ut.cpp
index f3d73895ad..bf32daf475 100644
--- a/util/generic/overloaded_ut.cpp
+++ b/util/generic/overloaded_ut.cpp
@@ -1,4 +1,4 @@
-#include <util/generic/overloaded.h>
+#include <util/generic/overloaded.h>
#include <library/cpp/testing/unittest/registar.h>
@@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TOverloadedTest) {
[&](double) { res = -1; },
[&](TType1) { res = -1; }},
v);
- UNIT_ASSERT_VALUES_EQUAL(res, 5);
+ UNIT_ASSERT_VALUES_EQUAL(res, 5);
}
Y_UNIT_TEST(TupleTest) {
@@ -48,35 +48,35 @@ Y_UNIT_TEST_SUITE(TOverloadedTest) {
[&](bool val) { res += "(bool) " + ToString(val) + ' '; },
});
- UNIT_ASSERT_VALUES_EQUAL(res, "(int) 5 (double) 3.14 (bool) 1 (int) 20 ");
+ UNIT_ASSERT_VALUES_EQUAL(res, "(int) 5 (double) 3.14 (bool) 1 (int) 20 ");
}
-
- Y_UNIT_TEST(ImplicitConversionsTest) {
+
+ Y_UNIT_TEST(ImplicitConversionsTest) {
using TTestVariant = std::variant<int, double, char>;
-
- // Purposefully exhibit inexact overload matched with implicit type
- // conversions
-
- // All cases implicitly cast to int
- auto matchAsInt = [](TTestVariant var) {
+
+ // Purposefully exhibit inexact overload matched with implicit type
+ // conversions
+
+ // All cases implicitly cast to int
+ auto matchAsInt = [](TTestVariant var) {
return std::visit(TOverloaded{
[](int val) { return val; },
}, var);
- };
-
- UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{17.77}), 17);
- UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{12345}), 12345);
- UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{'X'}), 88);
-
- // All cases implicitly cast to double
- auto matchAsDouble = [](TTestVariant var) {
+ };
+
+ UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{17.77}), 17);
+ UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{12345}), 12345);
+ UNIT_ASSERT_VALUES_EQUAL(matchAsInt(TTestVariant{'X'}), 88);
+
+ // All cases implicitly cast to double
+ auto matchAsDouble = [](TTestVariant var) {
return std::visit(TOverloaded{
[](double val) { return val; },
}, var);
- };
-
- UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{17.77}), 17.77);
- UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{12345}), 12345.0);
- UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{'X'}), 88.0);
- }
+ };
+
+ UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{17.77}), 17.77);
+ UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{12345}), 12345.0);
+ UNIT_ASSERT_VALUES_EQUAL(matchAsDouble(TTestVariant{'X'}), 88.0);
+ }
}