diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/generic/function_ut.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/function_ut.cpp')
-rw-r--r-- | util/generic/function_ut.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/util/generic/function_ut.cpp b/util/generic/function_ut.cpp index 8c70109737..3880295a9f 100644 --- a/util/generic/function_ut.cpp +++ b/util/generic/function_ut.cpp @@ -1,69 +1,69 @@ -#include "function.h" -#include "typetraits.h" - +#include "function.h" +#include "typetraits.h" + #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TestFunctionSignature) { - int FF(double x) { - return (int)x; - } - - int FFF(double x, char xx) { - return (int)x + (int)xx; - } - - struct A { - int F(double x) { - return FF(x); - } - }; - + int FF(double x) { + return (int)x; + } + + int FFF(double x, char xx) { + return (int)x + (int)xx; + } + + struct A { + int F(double x) { + return FF(x); + } + }; + Y_UNIT_TEST(TestPlainFunc) { - UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(FF)>, decltype(FF)); - } - + UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(FF)>, decltype(FF)); + } + Y_UNIT_TEST(TestMethod) { - UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(&A::F)>, decltype(FF)); - } - + UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(&A::F)>, decltype(FF)); + } + Y_UNIT_TEST(TestLambda) { - auto f = [](double x) -> int { - return FF(x); - }; - - UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF)); - } - + auto f = [](double x) -> int { + return FF(x); + }; + + UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF)); + } + Y_UNIT_TEST(TestFunction) { std::function<int(double)> f(FF); - - UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF)); - } - - template <class F> - void TestCT() { -#define FA(x) TFunctionArg<F, x> - - UNIT_ASSERT_TYPES_EQUAL(FA(0), double); - UNIT_ASSERT_TYPES_EQUAL(FA(1), char); - UNIT_ASSERT_TYPES_EQUAL(TFunctionResult<F>, int); - -#undef FA - } - + + UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF)); + } + + template <class F> + void TestCT() { +#define FA(x) TFunctionArg<F, x> + + UNIT_ASSERT_TYPES_EQUAL(FA(0), double); + UNIT_ASSERT_TYPES_EQUAL(FA(1), char); + UNIT_ASSERT_TYPES_EQUAL(TFunctionResult<F>, int); + +#undef FA + } + Y_UNIT_TEST(TestTypeErasureTraits) { - TestCT<std::function<int(double, char)>>(); - } - + TestCT<std::function<int(double, char)>>(); + } + Y_UNIT_TEST(TestPlainFunctionTraits) { - TestCT<decltype(FFF)>(); - } - + TestCT<decltype(FFF)>(); + } + Y_UNIT_TEST(TestLambdaTraits) { - auto fff = [](double xx, char xxx) -> int { - return FFF(xx, xxx); - }; - - TestCT<decltype(fff)>(); - } -} + auto fff = [](double xx, char xxx) -> int { + return FFF(xx, xxx); + }; + + TestCT<decltype(fff)>(); + } +} |