proxygen
WhenTest.cpp File Reference
#include <memory>
#include <mutex>
#include <folly/futures/Future.h>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Functions

 TEST (When, predicateFalse)
 
 TEST (When, predicateTrue)
 

Function Documentation

TEST ( When  ,
predicateFalse   
)

Definition at line 25 of file WhenTest.cpp.

References EXPECT_EQ, i, folly::makeFuture(), and folly::when().

25  {
26  int i = 0;
27  auto thunk = [&] { return makeFuture().thenValue([&](auto&&) { i += 1; }); };
28 
29  // false
30  auto f1 = folly::when(false, thunk);
31  f1.wait();
32  EXPECT_EQ(0, i);
33 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Future< Unit > when(bool p, F &&thunk)
Definition: Future-inl.h:2330
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
TEST ( When  ,
predicateTrue   
)

Definition at line 35 of file WhenTest.cpp.

References EXPECT_EQ, i, folly::makeFuture(), and folly::when().

35  {
36  int i = 0;
37  auto thunk = [&] { return makeFuture().thenValue([&](auto&&) { i += 1; }); };
38 
39  // true
40  auto f2 = folly::when(true, thunk);
41  f2.wait();
42  EXPECT_EQ(1, i);
43 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Future< Unit > when(bool p, F &&thunk)
Definition: Future-inl.h:2330
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310