| 50 | double constexpr kUnknownWeight = -1.0; |
| 51 | |
| 52 | void TestRoute(FakeEnding const & start, FakeEnding const & finish, size_t expectedLength, |
| 53 | vector<Segment> const * expectedRoute, double expectedWeight, WorldGraph & graph) |
| 54 | { |
| 55 | auto starter = MakeStarter(start, finish, graph); |
| 56 | vector<Segment> route; |
| 57 | double timeSec; |
| 58 | auto const resultCode = CalculateRoute(*starter, route, timeSec); |
| 59 | TEST_EQUAL(resultCode, AlgorithmForIndexGraphStarter::Result::OK, ()); |
| 60 | |
| 61 | TEST_GREATER(route.size(), 2, ()); |
| 62 | |
| 63 | vector<Segment> noFakeRoute; |
| 64 | for (auto const & s : route) |
| 65 | { |
| 66 | auto real = s; |
| 67 | if (!starter->ConvertToReal(real)) |
| 68 | continue; |
| 69 | noFakeRoute.push_back(real); |
| 70 | } |
| 71 | |
| 72 | TEST_EQUAL(noFakeRoute.size(), expectedLength, ("route =", noFakeRoute)); |
| 73 | |
| 74 | if (expectedWeight != kUnknownWeight) |
| 75 | { |
| 76 | double constexpr kEpsilon = 0.01; |
| 77 | TEST(AlmostEqualRel(timeSec, expectedWeight, kEpsilon), ("Expected weight:", expectedWeight, "got:", timeSec)); |
| 78 | } |
| 79 | |
| 80 | if (expectedRoute) |
| 81 | TEST_EQUAL(noFakeRoute, *expectedRoute, ()); |
| 82 | } |
| 83 | |
| 84 | void TestEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets, bool isOutgoing) |
| 85 | { |
no test coverage detected