diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-07-20 14:01:12 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:56:54 +0300 |
commit | 9ecb3f5c6c1556e6d66147edcea40783312402de (patch) | |
tree | 3cb3c9cff6a42886bede636983eb4a799955f01c /routing/routing_tests/astar_progress_test.cpp | |
parent | 09b082083df1332e668766294b8b3fa4d82a4e40 (diff) |
AStar progress class.
Diffstat (limited to 'routing/routing_tests/astar_progress_test.cpp')
-rw-r--r-- | routing/routing_tests/astar_progress_test.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/routing/routing_tests/astar_progress_test.cpp b/routing/routing_tests/astar_progress_test.cpp new file mode 100644 index 0000000000..57f6bb230f --- /dev/null +++ b/routing/routing_tests/astar_progress_test.cpp @@ -0,0 +1,51 @@ +#include "testing/testing.hpp" + +#include "routing/base/astar_progress.hpp" + +namespace routing_test +{ +using namespace routing; + +UNIT_TEST(DirectedAStarProgressCheck) +{ + m2::PointD start = m2::PointD(0, 1); + m2::PointD finish = m2::PointD(0, 3); + m2::PointD middle = m2::PointD(0, 2); + + AStarProgress progress(0, 100); + progress.Initialise(start, finish); + TEST_LESS(progress.GetProgressForDirectedAlgo(start), 0.1f, ()); + TEST_LESS(progress.GetProgressForDirectedAlgo(middle), 50.5f, ()); + TEST_GREATER(progress.GetProgressForDirectedAlgo(middle), 49.5f, ()); + TEST_GREATER(progress.GetProgressForDirectedAlgo(finish), 99.9f, ()); +} + +UNIT_TEST(DirectedAStarProgressCheckAtShiftedInterval) +{ + m2::PointD start = m2::PointD(0, 1); + m2::PointD finish = m2::PointD(0, 3); + m2::PointD middle = m2::PointD(0, 2); + + AStarProgress progress(50, 250); + progress.Initialise(start, finish); + TEST_LESS(progress.GetProgressForDirectedAlgo(start), 50.1f, ()); + TEST_LESS(progress.GetProgressForDirectedAlgo(middle), 150.5f, ()); + TEST_GREATER(progress.GetProgressForDirectedAlgo(middle), 145.5f, ()); + TEST_GREATER(progress.GetProgressForDirectedAlgo(finish), 245.9f, ()); +} + +UNIT_TEST(BidirectedAStarProgressCheck) +{ + m2::PointD start = m2::PointD(0, 0); + m2::PointD finish = m2::PointD(0, 4); + m2::PointD fWave = m2::PointD(0, 1); + m2::PointD bWave = m2::PointD(0, 3); + + AStarProgress progress(0.0f, 100.0f); + progress.Initialise(start, finish); + progress.GetProgressForBidirectedAlgo(fWave, finish); + float result = progress.GetProgressForBidirectedAlgo(bWave, start); + ASSERT_GREATER(result, 49.5, ()); + ASSERT_LESS(result, 50.5, ()); +} +} |