aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/future/future_ut.cpp
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-02-10 16:46:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:31 +0300
commit317da38588b7898a99fd9168571408123350012b (patch)
tree25eebc31526019ad39a6c1b13f492963d97ba439 /library/cpp/threading/future/future_ut.cpp
parent3b2241461d41d41ba1a706b0750c4f0f55c344f6 (diff)
downloadydb-317da38588b7898a99fd9168571408123350012b.tar.gz
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading/future/future_ut.cpp')
-rw-r--r--library/cpp/threading/future/future_ut.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp
index 05950a568d..9ddca66b37 100644
--- a/library/cpp/threading/future/future_ut.cpp
+++ b/library/cpp/threading/future/future_ut.cpp
@@ -260,11 +260,11 @@ namespace {
}
- Y_UNIT_TEST(ShouldWaitExceptionOrAll) {
+ Y_UNIT_TEST(ShouldWaitExceptionOrAll) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
- TFuture<void> future = WaitExceptionOrAll(promise1, promise2);
+ TFuture<void> future = WaitExceptionOrAll(promise1, promise2);
UNIT_ASSERT(!future.HasValue());
promise1.SetValue();
@@ -274,7 +274,7 @@ namespace {
UNIT_ASSERT(future.HasValue());
}
- Y_UNIT_TEST(ShouldWaitExceptionOrAllVector) {
+ Y_UNIT_TEST(ShouldWaitExceptionOrAllVector) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
@@ -282,7 +282,7 @@ namespace {
promises.push_back(promise1);
promises.push_back(promise2);
- TFuture<void> future = WaitExceptionOrAll(promises);
+ TFuture<void> future = WaitExceptionOrAll(promises);
UNIT_ASSERT(!future.HasValue());
promise1.SetValue();
@@ -292,7 +292,7 @@ namespace {
UNIT_ASSERT(future.HasValue());
}
- Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorWithValueType) {
+ Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorWithValueType) {
TPromise<int> promise1 = NewPromise<int>();
TPromise<int> promise2 = NewPromise<int>();
@@ -300,7 +300,7 @@ namespace {
promises.push_back(promise1);
promises.push_back(promise2);
- TFuture<void> future = WaitExceptionOrAll(promises);
+ TFuture<void> future = WaitExceptionOrAll(promises);
UNIT_ASSERT(!future.HasValue());
promise1.SetValue(0);
@@ -310,7 +310,7 @@ namespace {
UNIT_ASSERT(future.HasValue());
}
- Y_UNIT_TEST(ShouldWaitExceptionOrAllList) {
+ Y_UNIT_TEST(ShouldWaitExceptionOrAllList) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
@@ -318,7 +318,7 @@ namespace {
promises.push_back(promise1);
promises.push_back(promise2);
- TFuture<void> future = WaitExceptionOrAll(promises);
+ TFuture<void> future = WaitExceptionOrAll(promises);
UNIT_ASSERT(!future.HasValue());
promise1.SetValue();
@@ -328,10 +328,10 @@ namespace {
UNIT_ASSERT(future.HasValue());
}
- Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorEmpty) {
+ Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorEmpty) {
TVector<TFuture<void>> promises;
- TFuture<void> future = WaitExceptionOrAll(promises);
+ TFuture<void> future = WaitExceptionOrAll(promises);
UNIT_ASSERT(future.HasValue());
}
@@ -480,21 +480,21 @@ namespace {
UNIT_CHECK_GENERATED_EXCEPTION(promise.ExtractValue(), TFutureException);
}
- Y_UNIT_TEST(ShouldNotExtractFromSharedDefault) {
- UNIT_CHECK_GENERATED_EXCEPTION(MakeFuture<int>().ExtractValue(), TFutureException);
-
- struct TStorage {
- TString String = TString(100, 'a');
- };
- try {
- TString s = MakeFuture<TStorage>().ExtractValue().String;
- Y_UNUSED(s);
- } catch (TFutureException) {
- // pass
- }
- UNIT_ASSERT_VALUES_EQUAL(MakeFuture<TStorage>().GetValue().String, TString(100, 'a'));
- }
-
+ Y_UNIT_TEST(ShouldNotExtractFromSharedDefault) {
+ UNIT_CHECK_GENERATED_EXCEPTION(MakeFuture<int>().ExtractValue(), TFutureException);
+
+ struct TStorage {
+ TString String = TString(100, 'a');
+ };
+ try {
+ TString s = MakeFuture<TStorage>().ExtractValue().String;
+ Y_UNUSED(s);
+ } catch (TFutureException) {
+ // pass
+ }
+ UNIT_ASSERT_VALUES_EQUAL(MakeFuture<TStorage>().GetValue().String, TString(100, 'a'));
+ }
+
Y_UNIT_TEST(HandlingRepetitiveSet) {
TPromise<int> promise = NewPromise<int>();
promise.SetValue(42);
@@ -541,7 +541,7 @@ namespace {
Y_UNIT_TEST(WaitAllowsExtract) {
auto future = MakeFuture<int>(42);
TVector vec{future, future, future};
- WaitExceptionOrAll(vec).GetValue();
+ WaitExceptionOrAll(vec).GetValue();
WaitAny(vec).GetValue();
UNIT_ASSERT_EQUAL(future.ExtractValue(), 42);
@@ -553,30 +553,30 @@ namespace {
UNIT_ASSERT_EQUAL(future.ExtractValue(), 42);
}
-
- Y_UNIT_TEST(WaitExceptionOrAllException) {
- auto promise1 = NewPromise();
- auto promise2 = NewPromise();
- auto future1 = promise1.GetFuture();
- auto future2 = promise2.GetFuture();
- auto wait = WaitExceptionOrAll(future1, future2);
- promise2.SetException("foo-exception");
- wait.Wait();
- UNIT_ASSERT(future2.HasException());
- UNIT_ASSERT(!future1.HasValue() && !future1.HasException());
- }
-
- Y_UNIT_TEST(WaitAllException) {
- auto promise1 = NewPromise();
- auto promise2 = NewPromise();
- auto future1 = promise1.GetFuture();
- auto future2 = promise2.GetFuture();
- auto wait = WaitAll(future1, future2);
- promise2.SetException("foo-exception");
- UNIT_ASSERT(!wait.HasValue() && !wait.HasException());
- promise1.SetValue();
- UNIT_ASSERT_EXCEPTION_CONTAINS(wait.GetValueSync(), yexception, "foo-exception");
- }
+
+ Y_UNIT_TEST(WaitExceptionOrAllException) {
+ auto promise1 = NewPromise();
+ auto promise2 = NewPromise();
+ auto future1 = promise1.GetFuture();
+ auto future2 = promise2.GetFuture();
+ auto wait = WaitExceptionOrAll(future1, future2);
+ promise2.SetException("foo-exception");
+ wait.Wait();
+ UNIT_ASSERT(future2.HasException());
+ UNIT_ASSERT(!future1.HasValue() && !future1.HasException());
+ }
+
+ Y_UNIT_TEST(WaitAllException) {
+ auto promise1 = NewPromise();
+ auto promise2 = NewPromise();
+ auto future1 = promise1.GetFuture();
+ auto future2 = promise2.GetFuture();
+ auto wait = WaitAll(future1, future2);
+ promise2.SetException("foo-exception");
+ UNIT_ASSERT(!wait.HasValue() && !wait.HasException());
+ promise1.SetValue();
+ UNIT_ASSERT_EXCEPTION_CONTAINS(wait.GetValueSync(), yexception, "foo-exception");
+ }
Y_UNIT_TEST(FutureStateId) {
TestFutureStateId<void>();