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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2010-12-05 19:24:16 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-22 22:33:57 +0300
commitd6e12b7ce4bcbf0ccd1c07eb25de143422913c34 (patch)
treea7e910c330ce4da9b4f2d8be76067adece2561c4 /geometry/geometry_tests/common_test.cpp
One Month In Minsk. Made in Belarus.
Diffstat (limited to 'geometry/geometry_tests/common_test.cpp')
-rw-r--r--geometry/geometry_tests/common_test.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/geometry/geometry_tests/common_test.cpp b/geometry/geometry_tests/common_test.cpp
new file mode 100644
index 0000000000..d6dc8cb4db
--- /dev/null
+++ b/geometry/geometry_tests/common_test.cpp
@@ -0,0 +1,44 @@
+#include "../../base/SRC_FIRST.hpp"
+#include "../../base/macros.hpp"
+
+#include "equality.hpp"
+
+#include "../../testing/testing.hpp"
+
+#include "../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)), ());
+}