Welcome to mirror list, hosted at ThFree Co, Russian Federation.

nearest_edge_finder_tests.cpp « routing_tests « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 913317febb9abd59a80c4bc6f04352df39f47db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "testing/testing.hpp"

#include "routing/routing_tests/road_graph_builder.hpp"

#include "routing/nearest_edge_finder.hpp"

using namespace routing;
using namespace routing_test;

void TestNearestOnMock1(m2::PointD const & point, size_t const candidatesCount,
                        vector<pair<Edge, Junction>> const & expected)
{
  unique_ptr<RoadGraphMockSource> graph(new RoadGraphMockSource());
  InitRoadGraphMockSourceWithTest1(*graph);

  NearestEdgeFinder finder(point);
  for (size_t i = 0; i < graph->GetRoadCount(); ++i)
  {
    FeatureID const featureId = MakeTestFeatureID(i);
    finder.AddInformationSource(featureId, graph->GetRoadInfo(featureId));
  }

  vector<pair<Edge, Junction>> result;
  TEST(finder.HasCandidates(), ());
  finder.MakeResult(result, candidatesCount);

  TEST_EQUAL(result, expected, ());
}

UNIT_TEST(StarterPosAtBorder_Mock1Graph)
{
  vector<pair<Edge, Junction>> const expected = {make_pair(
      Edge(MakeTestFeatureID(0), true /* forward */, 0, MakeJunctionForTesting(m2::PointD(0, 0)),
           MakeJunctionForTesting(m2::PointD(5, 0))),
      MakeJunctionForTesting(m2::PointD(0, 0)))};
  TestNearestOnMock1(m2::PointD(0, 0), 1, expected);
}

UNIT_TEST(MiddleEdgeTest_Mock1Graph)
{
  vector<pair<Edge, Junction>> const expected = {make_pair(
      Edge(MakeTestFeatureID(0), true /* forward */, 0, MakeJunctionForTesting(m2::PointD(0, 0)),
           MakeJunctionForTesting(m2::PointD(5, 0))),
      MakeJunctionForTesting(m2::PointD(3, 0)))};
  TestNearestOnMock1(m2::PointD(3, 3), 1, expected);
}

UNIT_TEST(MiddleSegmentTest_Mock1Graph)
{
  vector<pair<Edge, Junction>> const expected = {
      make_pair(Edge(MakeTestFeatureID(0), true /* forward */, 2,
                     MakeJunctionForTesting(m2::PointD(10, 0)),
                     MakeJunctionForTesting(m2::PointD(15, 0))),
                MakeJunctionForTesting(m2::PointD(12.5, 0))),
      make_pair(Edge(MakeTestFeatureID(1), true /* forward */, 2,
                     MakeJunctionForTesting(m2::PointD(10, 0)),
                     MakeJunctionForTesting(m2::PointD(10, 5))),
                MakeJunctionForTesting(m2::PointD(10, 2.5)))};
  TestNearestOnMock1(m2::PointD(12.5, 2.5), 2, expected);
}