| 36 | } |
| 37 | |
| 38 | TEST(TraversalTest, OutputsDfsNoLoop) { |
| 39 | const string op = "OpIsNotImportantInThisTest"; |
| 40 | |
| 41 | GraphDef graph = ::tensorflow::test::function::GDef( // |
| 42 | {NDef("2", op, {"5"}, {}), // |
| 43 | NDef("0", op, {"5", "4"}, {}), // |
| 44 | NDef("1", op, {"4", "3"}, {}), // |
| 45 | NDef("3", op, {"2"}, {}), // |
| 46 | NDef("5", op, {}, {}), // |
| 47 | NDef("4", op, {}, {})}, // |
| 48 | /*funcs=*/{}); |
| 49 | |
| 50 | std::vector<const NodeDef*> start_nodes = {&graph.node(4), &graph.node(5)}; |
| 51 | |
| 52 | std::vector<string> pre_order; |
| 53 | std::vector<string> post_order; |
| 54 | std::vector<string> back_edges; |
| 55 | |
| 56 | GraphTopologyView graph_view; |
| 57 | TF_CHECK_OK(graph_view.InitializeFromGraph(graph)); |
| 58 | DfsTraversal(graph_view, start_nodes, TraversalDirection::kFollowOutputs, |
| 59 | MkCallbacks(&pre_order, &post_order, &back_edges)); |
| 60 | |
| 61 | const std::vector<string> expected_pre = {"4", "1", "0", "5", "2", "3"}; |
| 62 | const std::vector<string> expected_post = {"1", "0", "4", "3", "2", "5"}; |
| 63 | |
| 64 | EXPECT_EQ(pre_order, expected_pre); |
| 65 | EXPECT_EQ(post_order, expected_post); |
| 66 | EXPECT_TRUE(back_edges.empty()); |
| 67 | } |
| 68 | |
| 69 | TEST(TraversalTest, InputsDfsNoLoop) { |
| 70 | const string op = "OpIsNotImportantInThisTest"; |
nothing calls this directly
no test coverage detected