MCPcopy Create free account
hub / github.com/catboost/catboost / TestApplyLvalueCopyImpl

Function TestApplyLvalueCopyImpl

library/cpp/threading/future/future_ut.cpp:618–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616
617 template <typename T>
618 void TestApplyLvalueCopyImpl() {
619 size_t numCopies = 0;
620 TCopyCounter copyCounter(&numCopies);
621
622 auto promise = MakePromise<T>();
623
624 auto func = [copyCounter = std::move(copyCounter)] (const auto&) {};
625 const auto future = promise.GetFuture().Apply(func);
626
627 if constexpr (std::is_same_v<T, void>) {
628 promise.SetValue();
629 } else {
630 promise.SetValue(T());
631 }
632
633 future.GetValueSync();
634
635 UNIT_ASSERT_VALUES_EQUAL(numCopies, 1);
636 }
637
638 Y_UNIT_TEST(ApplyLvalueCopy) {
639 TestApplyLvalueCopyImpl<void>();

Callers

nothing calls this directly

Calls 6

GetValueSyncMethod · 0.80
moveFunction · 0.50
TClass · 0.50
ApplyMethod · 0.45
GetFutureMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected