MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_TEST

Function UNIT_TEST

libs/routing/routing_tests/fake_graph_test.cpp:95–132  ·  view source on GitHub ↗

Test constructs two fake graphs, performs checks during construction, merges graphs Calls FakeGraph::Append and checks topology of the merged graph.

Source from the content-addressed store, hash-verified

93// Test constructs two fake graphs, performs checks during construction, merges graphs
94// Calls FakeGraph::Append and checks topology of the merged graph.
95UNIT_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

Callers

nothing calls this directly

Calls 8

ConstructFakeGraphFunction · 0.85
GetSegmentFunction · 0.85
GetFakeVertexFunction · 0.85
TESTFunction · 0.85
GetSizeMethod · 0.45
AppendMethod · 0.45
emptyMethod · 0.45
GetEdgesMethod · 0.45

Tested by

no test coverage detected