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

Function UNIT_TEST

libs/routing/routing_tests/index_graph_test.cpp:132–177  ·  view source on GitHub ↗

R4 (one way down) R1 J2--------J3 -1 ^ v ^ v R0 *---J0----*---J1----* 0 ^ v ^ v R2 J4--------J5 1 R3 (one way up) y x: 0 1 2 3 4

Source from the content-addressed store, hash-verified

130// x: 0 1 2 3 4
131//
132UNIT_TEST(EdgesTest)
133{
134 unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>();
135 loader->AddRoad(0 /* featureId */, false, 1.0 /* speed */,
136 RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {3.0, 0.0}, {4.0, 0.0}}));
137 loader->AddRoad(1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{1.0, -1.0}, {3.0, -1.0}}));
138 loader->AddRoad(2 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{1.0, -1.0}, {3.0, -1.0}}));
139 loader->AddRoad(3 /* featureId */, true, 1.0 /* speed */,
140 RoadGeometry::Points({{1.0, 1.0}, {1.0, 0.0}, {1.0, -1.0}}));
141 loader->AddRoad(4 /* featureId */, true, 1.0 /* speed */,
142 RoadGeometry::Points({{3.0, -1.0}, {3.0, 0.0}, {3.0, 1.0}}));
143
144 traffic::TrafficCache const trafficCache;
145 IndexGraph graph(make_shared<Geometry>(std::move(loader)), CreateEstimatorForCar(trafficCache));
146
147 vector<Joint> joints;
148 joints.emplace_back(MakeJoint({{0, 1}, {3, 1}})); // J0
149 joints.emplace_back(MakeJoint({{0, 3}, {4, 1}})); // J1
150 joints.emplace_back(MakeJoint({{1, 0}, {3, 2}})); // J2
151 joints.emplace_back(MakeJoint({{1, 1}, {4, 0}})); // J3
152 joints.emplace_back(MakeJoint({{2, 0}, {3, 0}})); // J4
153 joints.emplace_back(MakeJoint({{2, 1}, {4, 2}})); // J5
154 graph.Import(joints);
155
156 TestOutgoingEdges(graph, {kTestNumMwmId, 0 /* featureId */, 0 /* segmentIdx */, true /* forward */},
157 {{kTestNumMwmId, 0, 0, false}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 3, 1, true}});
158 TestIngoingEdges(graph, {kTestNumMwmId, 0, 0, true}, {{kTestNumMwmId, 0, 0, false}});
159 TestOutgoingEdges(graph, {kTestNumMwmId, 0, 0, false}, {{kTestNumMwmId, 0, 0, true}});
160 TestIngoingEdges(graph, {kTestNumMwmId, 0, 0, false},
161 {{kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, false}, {kTestNumMwmId, 3, 0, true}});
162
163 TestOutgoingEdges(graph, {kTestNumMwmId, 0, 2, true},
164 {{kTestNumMwmId, 0, 2, false}, {kTestNumMwmId, 0, 3, true}, {kTestNumMwmId, 4, 1, true}});
165 TestIngoingEdges(graph, {kTestNumMwmId, 0, 2, true}, {{kTestNumMwmId, 0, 1, true}});
166 TestOutgoingEdges(graph, {kTestNumMwmId, 0, 2, false}, {{kTestNumMwmId, 0, 1, false}});
167 TestIngoingEdges(graph, {kTestNumMwmId, 0, 2, false},
168 {{kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, false}, {kTestNumMwmId, 4, 0, true}});
169
170 TestOutgoingEdges(graph, {kTestNumMwmId, 3, 0, true},
171 {{kTestNumMwmId, 3, 1, true}, {kTestNumMwmId, 0, 0, false}, {kTestNumMwmId, 0, 1, true}});
172 TestIngoingEdges(graph, {kTestNumMwmId, 3, 0, true}, {{kTestNumMwmId, 2, 0, false}});
173
174 TestOutgoingEdges(graph, {kTestNumMwmId, 4, 1, true}, {{kTestNumMwmId, 2, 0, false}});
175 TestIngoingEdges(graph, {kTestNumMwmId, 4, 1, true},
176 {{kTestNumMwmId, 4, 0, true}, {kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, false}});
177}
178
179// Roads R1:
180//

Callers

nothing calls this directly

Calls 15

PointsFunction · 0.85
CreateEstimatorForCarFunction · 0.85
MakeJointFunction · 0.85
TestIngoingEdgesFunction · 0.85
BuildWorldGraphFunction · 0.85
AbsDeltaFunction · 0.85
TestRouteFunction · 0.85
KmphToMpsFunction · 0.85
MakeStarterFunction · 0.85
TestRouteGeometryFunction · 0.85
SerializeFunction · 0.85
TestTopologyGraphFunction · 0.85

Tested by

no test coverage detected