MCPcopy Create free account
hub / github.com/comaps/comaps / TestContainsRectangular

Function TestContainsRectangular

libs/geometry/geometry_tests/region_tests.cpp:33–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31/// Region should have CCW orientation from left, down corner.
32template <class Point>
33void TestContainsRectangular(Point const * arr)
34{
35 m2::Region<Point> region;
36
37 size_t const count = 4;
38 region.Assign(arr, arr + count);
39
40 for (size_t i = 0; i < count; ++i)
41 {
42 TEST(region.Contains(arr[i]), ());
43
44 if constexpr (std::is_floating_point<typename Point::value_type>::value)
45 TEST(region.Contains((arr[i] + arr[(i + 1) % count]) / 2), ());
46 }
47
48 Point dx(1, 0);
49 Point dy(0, 1);
50
51 TEST(!region.Contains(arr[0] - dx), ());
52 TEST(!region.Contains(arr[0] - dy), ());
53 TEST(!region.Contains(arr[0] - dx - dy), ());
54 TEST(region.Contains(arr[0] + dx + dy), ());
55
56 TEST(!region.Contains(arr[1] + dx), ());
57 TEST(!region.Contains(arr[1] - dy), ());
58 TEST(!region.Contains(arr[1] + dx - dy), ());
59 TEST(region.Contains(arr[1] - dx + dy), ());
60
61 TEST(!region.Contains(arr[2] + dx), ());
62 TEST(!region.Contains(arr[2] + dy), ());
63 TEST(!region.Contains(arr[2] + dx + dy), ());
64 TEST(region.Contains(arr[2] - dx - dy), ());
65
66 TEST(!region.Contains(arr[3] - dx), ());
67 TEST(!region.Contains(arr[3] + dy), ());
68 TEST(!region.Contains(arr[3] - dx + dy), ());
69 TEST(region.Contains(arr[3] + dx - dy), ());
70}
71
72template <class Region>
73void TestContains()

Callers 1

TestContainsFunction · 0.85

Calls 3

TESTFunction · 0.85
AssignMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected