Test constructs two fake graphs, performs checks during construction, merges graphs Calls FakeGraph::Append and checks topology of the merged graph.
| 93 | // Test constructs two fake graphs, performs checks during construction, merges graphs |
| 94 | // Calls FakeGraph::Append and checks topology of the merged graph. |
| 95 | UNIT_TEST(FakeGraphTest) |
| 96 | { |
| 97 | uint32_t const fake0 = 5; |
| 98 | uint32_t const real0 = 3; |
| 99 | uint32_t const fake1 = 4; |
| 100 | uint32_t const real1 = 2; |
| 101 | auto fakeGraph0 = ConstructFakeGraph(0, fake0, real0); |
| 102 | TEST_EQUAL(fakeGraph0.GetSize(), fake0 + real0, ("Wrong fake graph size")); |
| 103 | |
| 104 | auto const fakeGraph1 = ConstructFakeGraph(static_cast<uint32_t>(fakeGraph0.GetSize()), fake1, real1); |
| 105 | TEST_EQUAL(fakeGraph1.GetSize(), fake1 + real1, ("Wrong fake graph size")); |
| 106 | |
| 107 | fakeGraph0.Append(fakeGraph1); |
| 108 | TEST_EQUAL(fakeGraph0.GetSize(), fake0 + real0 + fake1 + real1, ("Wrong size of merged graph")); |
| 109 | |
| 110 | // Test merged graph. |
| 111 | for (uint32_t i = 0; i + 1 < fakeGraph0.GetSize(); ++i) |
| 112 | { |
| 113 | auto const segmentFrom = GetSegment(i); |
| 114 | auto const segmentTo = GetSegment(i + 1); |
| 115 | |
| 116 | TEST_EQUAL(fakeGraph0.GetVertex(segmentFrom), GetFakeVertex(i), ("Wrong segment to vertex mapping.")); |
| 117 | TEST_EQUAL(fakeGraph0.GetVertex(segmentTo), GetFakeVertex(i + 1), ("Wrong segment to vertex mapping.")); |
| 118 | // No connection to next fake segment; next segment was in separate fake graph before Append. |
| 119 | if (i + 1 == fake0 + real0) |
| 120 | { |
| 121 | TEST(fakeGraph0.GetEdges(segmentFrom, true /* isOutgoing */).empty(), ("Wrong ingoing edges set.")); |
| 122 | TEST(fakeGraph0.GetEdges(segmentTo, false /* isOutgoing */).empty(), ("Wrong ingoing edges set.")); |
| 123 | } |
| 124 | else |
| 125 | { |
| 126 | TEST_EQUAL(fakeGraph0.GetEdges(segmentFrom, true /* isOutgoing */), set<Segment>{segmentTo}, |
| 127 | ("Wrong ingoing edges set.")); |
| 128 | TEST_EQUAL(fakeGraph0.GetEdges(segmentTo, false /* isOutgoing */), set<Segment>{segmentFrom}, |
| 129 | ("Wrong ingoing edges set.")); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } // namespace fake_graph_test |
nothing calls this directly
no test coverage detected