diff options
author | ishfb <ishfb@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 069c69f58fd78de3cf2e6eb2304047281e21fb65 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/threading/future/legacy_future_ut.cpp | |
parent | 0170772a2dbf133f32e17ca137ff64790d43831f (diff) | |
download | ydb-069c69f58fd78de3cf2e6eb2304047281e21fb65.tar.gz |
Restoring authorship annotation for <ishfb@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/future/legacy_future_ut.cpp')
-rw-r--r-- | library/cpp/threading/future/legacy_future_ut.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp index 67c0ea504e..ff63db1725 100644 --- a/library/cpp/threading/future/legacy_future_ut.cpp +++ b/library/cpp/threading/future/legacy_future_ut.cpp @@ -1,73 +1,73 @@ -#include "legacy_future.h" - +#include "legacy_future.h" + #include <library/cpp/testing/unittest/registar.h> - -namespace NThreading { + +namespace NThreading { Y_UNIT_TEST_SUITE(TLegacyFutureTest) { int intf() { return 17; } - + Y_UNIT_TEST(TestIntFunction) { TLegacyFuture<int> f((&intf)); UNIT_ASSERT_VALUES_EQUAL(17, f.Get()); } - + static int r; - + void voidf() { r = 18; } - + Y_UNIT_TEST(TestVoidFunction) { r = 0; TLegacyFuture<> f((&voidf)); f.Get(); UNIT_ASSERT_VALUES_EQUAL(18, r); } - + struct TSampleClass { int mValue; - + TSampleClass(int value) : mValue(value) { } - + int Calc() { return mValue + 1; } }; - + Y_UNIT_TEST(TestMethod) { TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3))); UNIT_ASSERT_VALUES_EQUAL(4, f11.Get()); - + TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory()); UNIT_ASSERT_VALUES_EQUAL(4, f12.Get()); - + TSampleClass c(5); - + TLegacyFuture<int> f21(std::bind(&TSampleClass::Calc, std::ref(c))); UNIT_ASSERT_VALUES_EQUAL(6, f21.Get()); - + TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory()); UNIT_ASSERT_VALUES_EQUAL(6, f22.Get()); } - + struct TSomeThreadPool: public IThreadFactory {}; - + Y_UNIT_TEST(TestFunction) { std::function<int()> f((&intf)); - + UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get()); UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get()); - + if (false) { TSomeThreadPool* q = nullptr; TLegacyFuture<int>(f, q); // just check compiles, do not start } - } - } - -} + } + } + +} |