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:
Diffstat (limited to 'geometry/geometry_tests/diamond_box_tests.cpp')
-rw-r--r--geometry/geometry_tests/diamond_box_tests.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/geometry/geometry_tests/diamond_box_tests.cpp b/geometry/geometry_tests/diamond_box_tests.cpp
new file mode 100644
index 0000000000..a3ed68f0e4
--- /dev/null
+++ b/geometry/geometry_tests/diamond_box_tests.cpp
@@ -0,0 +1,53 @@
+#include "testing/testing.hpp"
+
+#include "geometry/diamond_box.hpp"
+#include "geometry/point2d.hpp"
+
+using namespace m2;
+
+namespace
+{
+UNIT_TEST(DiamondBox_Smoke)
+{
+ {
+ DiamondBox dbox;
+ TEST(!dbox.HasPoint(0, 0), ());
+ }
+
+ {
+ DiamondBox dbox;
+ dbox.Add(0, 0);
+ TEST(dbox.HasPoint(0, 0), ());
+ TEST(!dbox.HasPoint(0, 1), ());
+ TEST(!dbox.HasPoint(1, 0), ());
+ TEST(!dbox.HasPoint(1, 1), ());
+ TEST(!dbox.HasPoint(0.5, 0.5), ());
+
+ dbox.Add(1, 1);
+ TEST(dbox.HasPoint(0, 0), ());
+ TEST(dbox.HasPoint(1, 1), ());
+ TEST(dbox.HasPoint(0.5, 0.5), ());
+ TEST(!dbox.HasPoint(1, 0), ());
+ TEST(!dbox.HasPoint(0, 1), ());
+ }
+
+ {
+ DiamondBox dbox;
+
+ dbox.Add(0, 1);
+ dbox.Add(0, -1);
+ dbox.Add(-1, 0);
+ dbox.Add(1, 0);
+ TEST(dbox.HasPoint(0, 0), ());
+ TEST(dbox.HasPoint(0.5, 0.5), ());
+ TEST(dbox.HasPoint(0.5, -0.5), ());
+ TEST(dbox.HasPoint(-0.5, 0.5), ());
+ TEST(dbox.HasPoint(-0.5, -0.5), ());
+
+ TEST(!dbox.HasPoint(0.51, 0.51), ());
+ TEST(!dbox.HasPoint(0.51, -0.51), ());
+ TEST(!dbox.HasPoint(-0.51, 0.51), ());
+ TEST(!dbox.HasPoint(-0.51, -0.51), ());
+ }
+}
+} // namespace