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

common_test.cpp « geometry_tests « geometry - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7ffbbb2af09855dafd019a97bd36b087fd0b1648 (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
#include "base/SRC_FIRST.hpp"
#include "base/macros.hpp"

#include "geometry/geometry_tests/equality.hpp"

#include "testing/testing.hpp"

#include "geometry/rect2d.hpp"

using namespace test;

UNIT_TEST(Rect)
{
  m2::Rect<double> rect(0, 0, 500, 300);

  double factor[] = { 0.2, 0.3, 0.5, 0.7, 1.0, 1.3, 1.5, 2.0 };
  for (size_t i = 0; i < ARRAY_SIZE(factor); ++i)
  {
    m2::Rect<double> r(rect);
    r.Scale(factor[i]);
    TEST(is_equal_center(rect, r), ());

    r = rect;
    r.Scale(-factor[i]);
    TEST(is_equal_center(rect, r), ());
  }

  m2::RectD external(0, 0, 100, 100);
  TEST(external.IsIntersect(m2::RectD(10, 10, 90, 90)), ());
  TEST(external.IsPointInside(m2::PointD(5, 33)), ());
  TEST(external.IsIntersect(m2::RectD(99, 99, 1000, 1000)), ());
}

UNIT_TEST(Point)
{
  double const l = sqrt(2.0);
  double const a = math::pi / 4.0;
  m2::PointD const start(0.0, 0.0);

  TEST(is_equal(start.Move(l, a), m2::PointD(1, 1)), ());
  TEST(is_equal(start.Move(l, math::pi - a), m2::PointD(-1, 1)), ());
  TEST(is_equal(start.Move(l, -math::pi + a), m2::PointD(-1, -1)), ());
  TEST(is_equal(start.Move(l, - a), m2::PointD(1, -1)), ());
}