proxygen
FutureDAGTest Struct Reference
Inheritance diagram for FutureDAGTest:
testing::Test

Classes

struct  TestNode
 

Public Types

typedef FutureDAG::Handle Handle
 
- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 

Public Member Functions

Handle add ()
 
void reset ()
 
void remove (Handle a)
 
void dependency (Handle a, Handle b)
 
void checkOrder ()
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Public Attributes

const std::shared_ptr< FutureDAGdag = FutureDAG::create()
 
std::map< Handle, std::unique_ptr< TestNode > > nodes
 
std::vector< Handleorder
 

Additional Inherited Members

- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 

Detailed Description

Definition at line 22 of file FutureDAGTest.cpp.

Member Typedef Documentation

Definition at line 23 of file FutureDAGTest.cpp.

Member Function Documentation

Handle FutureDAGTest::add ( )
inline

Definition at line 25 of file FutureDAGTest.cpp.

References folly::gen::move.

25  {
26  auto node = std::make_unique<TestNode>(this);
27  auto handle = node->handle;
28  nodes.emplace(handle, std::move(node));
29  return handle;
30  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::map< Handle, std::unique_ptr< TestNode > > nodes
void FutureDAGTest::checkOrder ( )
inline

Definition at line 68 of file FutureDAGTest.cpp.

References EXPECT_EQ, EXPECT_TRUE, and order.

68  {
69  EXPECT_EQ(nodes.size(), order.size());
70  for (auto& kv : nodes) {
71  auto handle = kv.first;
72  auto& node = kv.second;
73  auto it = order.begin();
74  while (*it != handle) {
75  it++;
76  }
77  for (auto dep : node->dependencies) {
78  EXPECT_TRUE(std::find(it, order.end(), dep) == order.end());
79  }
80  }
81  }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::vector< Handle > order
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::map< Handle, std::unique_ptr< TestNode > > nodes
void FutureDAGTest::dependency ( Handle  a,
Handle  b 
)
inline

Definition at line 63 of file FutureDAGTest.cpp.

63  {
64  nodes.at(b)->dependencies.insert(a);
65  dag->dependency(a, b);
66  }
char b
char a
const std::shared_ptr< FutureDAG > dag
std::map< Handle, std::unique_ptr< TestNode > > nodes
void FutureDAGTest::remove ( Handle  a)
inline

Definition at line 55 of file FutureDAGTest.cpp.

References a.

55  {
56  for (auto& node : nodes) {
57  node.second->dependencies.erase(a);
58  }
59  nodes.erase(a);
60  dag->remove(a);
61  }
char a
const std::shared_ptr< FutureDAG > dag
std::map< Handle, std::unique_ptr< TestNode > > nodes
void FutureDAGTest::reset ( )
inline

Definition at line 32 of file FutureDAGTest.cpp.

32  {
33  Handle source_node;
34  std::unordered_set<Handle> memo;
35  for (auto& node : nodes) {
36  for (Handle handle : node.second->dependencies) {
37  memo.insert(handle);
38  }
39  }
40  for (auto& node : nodes) {
41  if (memo.find(node.first) == memo.end()) {
42  source_node = node.first;
43  }
44  }
45  for (auto it = nodes.cbegin(); it != nodes.cend();) {
46  if (it->first != source_node) {
47  it = nodes.erase(it);
48  } else {
49  ++it;
50  }
51  }
52  dag->reset();
53  }
FutureDAG::Handle Handle
const std::shared_ptr< FutureDAG > dag
std::map< Handle, std::unique_ptr< TestNode > > nodes

Member Data Documentation

const std::shared_ptr<FutureDAG> FutureDAGTest::dag = FutureDAG::create()

Definition at line 96 of file FutureDAGTest.cpp.

std::map<Handle, std::unique_ptr<TestNode> > FutureDAGTest::nodes

Definition at line 97 of file FutureDAGTest.cpp.

std::vector<Handle> FutureDAGTest::order

Definition at line 98 of file FutureDAGTest.cpp.

Referenced by FutureDAGTest::TestNode::TestNode().


The documentation for this struct was generated from the following file: