proxygen
PollTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (Poll, ready)
 
 TEST (Poll, notReady)
 
 TEST (Poll, exception)
 

Function Documentation

TEST ( Poll  ,
ready   
)

Definition at line 22 of file PollTest.cpp.

References EXPECT_EQ, f, folly::Promise< T >::getFuture(), and folly::Promise< T >::setValue().

22  {
23  Promise<int> p;
24  auto f = p.getFuture();
25  p.setValue(42);
26  EXPECT_EQ(42, f.poll().value().value());
27 }
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Future< T > getFuture()
Definition: Promise-inl.h:97
std::enable_if< std::is_same< Unit, B >::value, void >::type setValue()
Definition: Promise.h:326
TEST ( Poll  ,
notReady   
)

Definition at line 29 of file PollTest.cpp.

References EXPECT_FALSE, f, and folly::Promise< T >::getFuture().

29  {
30  Promise<int> p;
31  auto f = p.getFuture();
32  EXPECT_FALSE(f.poll().hasValue());
33 }
auto f
Future< T > getFuture()
Definition: Promise-inl.h:97
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( Poll  ,
exception   
)

Definition at line 35 of file PollTest.cpp.

References EXPECT_TRUE, f, folly::Promise< T >::getFuture(), and folly::Promise< T >::setWith().

35  {
36  Promise<Unit> p;
37  auto f = p.getFuture();
38  p.setWith([] { throw std::runtime_error("Runtime"); });
39  EXPECT_TRUE(f.poll().value().hasException());
40 }
auto f
void setWith(F &&func)
Definition: Promise-inl.h:137
Future< T > getFuture()
Definition: Promise-inl.h:97
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859