proxygen
TimedDrivableExecutorTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (TimedDrivableExecutor, runIsStable)
 
 TEST (TimedDrivableExecutor, drainIsNotStable)
 
 TEST (TimedDrivableExecutor, try_drive)
 
 TEST (TimedDrivableExecutor, try_drive_for)
 
 TEST (TimedDrivableExecutor, try_drive_until)
 

Function Documentation

TEST ( TimedDrivableExecutor  ,
runIsStable   
)

Definition at line 25 of file TimedDrivableExecutorTest.cpp.

References folly::TimedDrivableExecutor::add(), count, EXPECT_EQ, folly::TimedDrivableExecutor::run(), and x.

25  {
26  size_t count = 0;
28  auto f1 = [&]() { count++; };
29  auto f2 = [&]() {
30  x.add(f1);
31  x.add(f1);
32  };
33  x.add(f2);
34  x.run();
35  EXPECT_EQ(count, 0);
36 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
int * count
TEST ( TimedDrivableExecutor  ,
drainIsNotStable   
)

Definition at line 38 of file TimedDrivableExecutorTest.cpp.

References folly::TimedDrivableExecutor::add(), count, folly::TimedDrivableExecutor::drain(), EXPECT_EQ, and x.

38  {
39  size_t count = 0;
41  auto f1 = [&]() { count++; };
42  auto f2 = [&]() {
43  x.add(f1);
44  x.add(f1);
45  };
46  x.add(f2);
47  x.drain();
48  EXPECT_EQ(count, 2);
49 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
int * count
TEST ( TimedDrivableExecutor  ,
try_drive   
)

Definition at line 51 of file TimedDrivableExecutorTest.cpp.

References folly::TimedDrivableExecutor::add(), count, EXPECT_EQ, folly::TimedDrivableExecutor::try_drive(), and x.

51  {
52  size_t count = 0;
54  auto f1 = [&]() { count++; };
55  x.try_drive();
56  EXPECT_EQ(count, 0);
57  x.add(f1);
58  x.try_drive();
59  EXPECT_EQ(count, 1);
60 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
int * count
TEST ( TimedDrivableExecutor  ,
try_drive_for   
)

Definition at line 62 of file TimedDrivableExecutorTest.cpp.

References folly::TimedDrivableExecutor::add(), count, EXPECT_EQ, folly::TimedDrivableExecutor::try_drive_for(), and x.

62  {
63  size_t count = 0;
65  auto f1 = [&]() { count++; };
66  x.try_drive_for(std::chrono::milliseconds(100));
67  EXPECT_EQ(count, 0);
68  x.add(f1);
69  x.try_drive_for(std::chrono::milliseconds(100));
70  EXPECT_EQ(count, 1);
71 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const int x
bool try_drive_for(const std::chrono::duration< Rep, Period > &timeout) noexcept
int * count
TEST ( TimedDrivableExecutor  ,
try_drive_until   
)

Definition at line 73 of file TimedDrivableExecutorTest.cpp.

References folly::TimedDrivableExecutor::add(), count, EXPECT_EQ, now(), folly::TimedDrivableExecutor::try_drive_until(), and x.

73  {
74  size_t count = 0;
76  auto f1 = [&]() { count++; };
78  std::chrono::system_clock::now() + std::chrono::milliseconds(100));
79  EXPECT_EQ(count, 0);
80  x.add(f1);
82  std::chrono::system_clock::now() + std::chrono::milliseconds(100));
83  EXPECT_EQ(count, 1);
84 }
bool try_drive_until(const std::chrono::time_point< Clock, Duration > &deadline) noexcept
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::chrono::steady_clock::time_point now()
const int x
int * count