mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-04 11:53:47 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
75
geometry/geometry_tests/calipers_box_tests.cpp
Normal file
75
geometry/geometry_tests/calipers_box_tests.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "geometry/calipers_box.hpp"
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace calipers_box_tests
|
||||
{
|
||||
using namespace m2;
|
||||
using namespace std;
|
||||
|
||||
UNIT_TEST(CalipersBox_Smoke)
|
||||
{
|
||||
{
|
||||
CalipersBox const cbox(vector<PointD>{});
|
||||
TEST(cbox.Points().empty(), ());
|
||||
TEST(!cbox.HasPoint(0, 0), ());
|
||||
TEST(!cbox.HasPoint(0, 1), ());
|
||||
TEST(!cbox.HasPoint(1, 0), ());
|
||||
}
|
||||
|
||||
{
|
||||
vector<PointD> const points = {{PointD(2, 3)}};
|
||||
CalipersBox const cbox(points);
|
||||
TEST_EQUAL(cbox.Points(), points, ());
|
||||
TEST(cbox.HasPoint(2, 3), ());
|
||||
TEST(!cbox.HasPoint(4, 6), ());
|
||||
TEST(!cbox.HasPoint(0, 0), ());
|
||||
}
|
||||
|
||||
{
|
||||
vector<PointD> const points = {{PointD(2, 3), PointD(2, 3), PointD(2, 3)}};
|
||||
CalipersBox const cbox(points);
|
||||
TEST_EQUAL(cbox.Points(), vector<PointD>{{PointD(2, 3)}}, ());
|
||||
}
|
||||
|
||||
{
|
||||
vector<PointD> const points = {{PointD(1, 1), PointD(1, 2)}};
|
||||
CalipersBox const cbox(points);
|
||||
TEST_EQUAL(cbox.Points(), points, ());
|
||||
TEST(cbox.HasPoint(1, 1.5), ());
|
||||
TEST(!cbox.HasPoint(1, 3), ());
|
||||
TEST(!cbox.HasPoint(0, 0), ());
|
||||
}
|
||||
|
||||
{
|
||||
vector<PointD> const points = {
|
||||
{PointD(0, 0), PointD(-2, 3), PointD(1, 5), PointD(3, 2), PointD(1, 2), PointD(0, 3)}};
|
||||
CalipersBox const cbox(points);
|
||||
TEST_EQUAL(cbox.Points(),
|
||||
(vector<PointD>{{PointD(-2, 3), PointD(0, 0), PointD(3, 2), PointD(1, 5)}}), ());
|
||||
for (auto const & p : points)
|
||||
TEST(cbox.HasPoint(p), (p));
|
||||
TEST(!cbox.HasPoint(1, 0), ());
|
||||
}
|
||||
|
||||
{
|
||||
vector<PointD> const points = {{PointD(0, 0), PointD(1, 0), PointD(0, 5), PointD(1, 5),
|
||||
PointD(-2, 2), PointD(-2, 3), PointD(3, 2), PointD(3, 3)}};
|
||||
vector<PointD> const expected = {
|
||||
{PointD(-2.5, 2.5), PointD(0.5, -0.5), PointD(3.5, 2.5), PointD(0.5, 5.5)}};
|
||||
CalipersBox const cbox(points);
|
||||
TEST_EQUAL(cbox.Points(), expected, ());
|
||||
|
||||
for (auto const & p : points)
|
||||
TEST(cbox.HasPoint(p), (p));
|
||||
|
||||
TEST(cbox.HasPoint(0, 2), ());
|
||||
|
||||
TEST(!cbox.HasPoint(2, 0), ());
|
||||
TEST(!cbox.HasPoint(4, 2), ());
|
||||
}
|
||||
}
|
||||
} // namespace calipers_box_tests
|
||||
Reference in New Issue
Block a user