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

polyline_point_to_int64_test.cpp « indexer_tests « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff0524fee1dd8ea8053806f73e8b0d4e32fff35a (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
#include "testing/testing.hpp"

#include "indexer/indexer_tests/test_polylines.hpp"

#include "indexer/cell_id.hpp"

#include "coding/point_to_integer.hpp"

#include "base/logging.hpp"

#include "std/cmath.hpp"
#include "std/utility.hpp"

namespace
{
double const g_eps = MercatorBounds::GetCellID2PointAbsEpsilon();
uint32_t const g_coordBits = POINT_COORD_BITS;

void CheckEqualPoints(m2::PointD const & p1, m2::PointD const & p2)
{
  TEST(p1.EqualDxDy(p2, g_eps), (p1, p2));

  TEST_GREATER_OR_EQUAL(p1.x, -180.0, ());
  TEST_GREATER_OR_EQUAL(p1.y, -180.0, ());
  TEST_LESS_OR_EQUAL(p1.x, 180.0, ());
  TEST_LESS_OR_EQUAL(p1.y, 180.0, ());

  TEST_GREATER_OR_EQUAL(p2.x, -180.0, ());
  TEST_GREATER_OR_EQUAL(p2.y, -180.0, ());
  TEST_LESS_OR_EQUAL(p2.x, 180.0, ());
  TEST_LESS_OR_EQUAL(p2.y, 180.0, ());
}
}

UNIT_TEST(PointToInt64_DataSet1)
{
  for (size_t i = 0; i < ARRAY_SIZE(index_test::arr1); ++i)
  {
    m2::PointD const pt(index_test::arr1[i].x, index_test::arr1[i].y);
    int64_t const id = PointToInt64(pt, g_coordBits);
    m2::PointD const pt1 = Int64ToPoint(id, g_coordBits);

    CheckEqualPoints(pt, pt1);

    int64_t const id1 = PointToInt64(pt1, g_coordBits);
    TEST_EQUAL(id, id1, (pt, pt1));
  }
}