diff options
author | AlexSm <alex@ydb.tech> | 2023-12-27 23:31:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 23:31:58 +0100 |
commit | d67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch) | |
tree | 8674f2f1570877cb653e7ddcff37ba00288de15a /library/cpp/threading/future/future_ut.cpp | |
parent | 1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff) | |
download | ydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz |
Import libs 4 (#758)
Diffstat (limited to 'library/cpp/threading/future/future_ut.cpp')
-rw-r--r-- | library/cpp/threading/future/future_ut.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index 05950a568d..26f8fa9e9c 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -635,6 +635,28 @@ namespace { TestApplyLvalueCopyImpl<void>(); TestApplyLvalueCopyImpl<int>(); } + + Y_UNIT_TEST(ReturnForwardingTypeDeduction) { + const TString e = TString(80, 'a'); + TString l = TString(80, 'a'); + + TFuture<TString> futureL = MakeFuture().Return(l); + UNIT_ASSERT_VALUES_EQUAL(futureL.GetValue(), e); + UNIT_ASSERT_VALUES_EQUAL(l, e); + + TFuture<TString> futureR = MakeFuture().Return(std::move(l)); + UNIT_ASSERT_VALUES_EQUAL(futureR.GetValue(), e); + } + + Y_UNIT_TEST(ReturnForwardingCopiesCount) { + size_t numCopies = 0; + TCopyCounter copyCounter(&numCopies); + + auto returnedCounter = MakeFuture().Return(std::move(copyCounter)).ExtractValueSync(); + Y_DO_NOT_OPTIMIZE_AWAY(returnedCounter); + + UNIT_ASSERT_VALUES_EQUAL(numCopies, 0); + } } } |