diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/function_ut.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 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 3880295a9f..8c70109737 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)>(); + } +} |