diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-08-14 12:49:26 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:46 +0300 |
commit | 958008d5c68fb79bd329361d7edc267cf23682f3 (patch) | |
tree | 9da62ed440d087b939deb77547fa808bb0a405d6 /routing/routing_tests/followed_polyline_test.cpp | |
parent | 7ed2944c73377033dc37d84f02466a9cbf6700a4 (diff) |
[routing] Tests for GetDistanceM method.
Diffstat (limited to 'routing/routing_tests/followed_polyline_test.cpp')
-rw-r--r-- | routing/routing_tests/followed_polyline_test.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/routing/routing_tests/followed_polyline_test.cpp b/routing/routing_tests/followed_polyline_test.cpp index ab98b05661..abb7da1858 100644 --- a/routing/routing_tests/followed_polyline_test.cpp +++ b/routing/routing_tests/followed_polyline_test.cpp @@ -57,8 +57,30 @@ UNIT_TEST(FollowedPolylineFollowingTestByPrediction) MercatorBounds::RectByCenterXYAndSizeInMeters({0.002, 0.003}, 20000), dist); TEST_EQUAL(polyline.GetCurrentIter().m_ind, 1, ()); TEST_LESS_OR_EQUAL(MercatorBounds::DistanceOnEarth(polyline.GetCurrentIter().m_pt, - m2::PointD(0.003, 0.003)), - 0.1, ()); + m2::PointD(0.003, 0.003)), 0.1, ()); +} + +UNIT_TEST(FollowedPolylineDistanceCalculationTest) +{ + // Test full length case. + FollowedPolyline polyline(kTestDirectedPolyline.Begin(), kTestDirectedPolyline.End()); + double distance = polyline.GetDistanceM(polyline.Begin(), polyline.End()); + double masterDistance = MercatorBounds::DistanceOnEarth(kTestDirectedPolyline.Front(), + kTestDirectedPolyline.Back()); + ASSERT_LESS(pow(distance - masterDistance, 2), 0.001, (distance, masterDistance)); + + // Test partial length case. + polyline.UpdateProjection(MercatorBounds::RectByCenterXYAndSizeInMeters({3, 0}, 2)); + distance = polyline.GetDistanceM(polyline.GetCurrentIter(), polyline.End()); + masterDistance = MercatorBounds::DistanceOnEarth(kTestDirectedPolyline.GetPoint(1), + kTestDirectedPolyline.Back()); + ASSERT_LESS(pow(distance - masterDistance, 2), 0.001, (distance, masterDistance)); + // Test point in the middle case. + polyline.UpdateProjection(MercatorBounds::RectByCenterXYAndSizeInMeters({4, 0}, 2)); + distance = polyline.GetDistanceM(polyline.GetCurrentIter(), polyline.End()); + masterDistance = MercatorBounds::DistanceOnEarth(m2::PointD(4, 0), + kTestDirectedPolyline.Back()); + ASSERT_LESS(pow(distance - masterDistance, 2), 0.001, (distance, masterDistance)); } } // namespace routing_test |