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

Function TestContains

libs/geometry/geometry_tests/region_tests.cpp:73–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72template <class Region>
73void TestContains()
74{
75 Region region;
76 ContainsChecker<Region> checker(region);
77
78 // point type
79 using P = typename Region::Value;
80
81 // rectangular polygon
82 {
83 P const data[] = {P(1, 1), P(10, 1), P(10, 10), P(1, 10)};
84 TestContainsRectangular(data);
85 }
86 {
87 P const data[] = {P(-100, -100), P(-50, -100), P(-50, -50), P(-100, -50)};
88 TestContainsRectangular(data);
89 }
90 {
91 P const data[] = {P(-2000000000, -2000000000), P(-1000000000, -2000000000), P(-1000000000, -1000000000),
92 P(-2000000000, -1000000000)};
93 TestContainsRectangular(data);
94 }
95 {
96 P const data[] = {P(1000000000, 1000000000), P(2000000000, 1000000000), P(2000000000, 2000000000),
97 P(1000000000, 2000000000)};
98 TestContainsRectangular(data);
99 }
100
101 // triangle
102 {
103 P const data[] = {P(0, 0), P(2, 0), P(2, 2)};
104 region.Assign(data, data + ARRAY_SIZE(data));
105 }
106 TEST_EQUAL(region.GetRect(), m2::Rect<typename P::value_type>(0, 0, 2, 2), ());
107 TEST(region.Contains(P(2, 0)), ());
108 TEST(region.Contains(P(1, 1)), ("point on diagonal"));
109 TEST(!region.Contains(P(33, 0)), ());
110 region.ForEachPoint(checker);
111
112 // complex polygon
113 {
114 P const data[] = {P(0, 0), P(2, 0), P(2, 2), P(3, 1), P(4, 2), P(5, 2), P(3, 3), P(3, 2), P(2, 4), P(6, 3),
115 P(7, 4), P(7, 2), P(8, 5), P(8, 7), P(7, 7), P(8, 8), P(5, 9), P(6, 6), P(5, 7), P(4, 6),
116 P(4, 8), P(3, 7), P(2, 7), P(3, 6), P(4, 4), P(0, 7), P(2, 3), P(0, 2)};
117 region.Assign(data, data + ARRAY_SIZE(data));
118 }
119 TEST_EQUAL(region.GetRect(), m2::Rect<typename P::value_type>(0, 0, 8, 9), ());
120 TEST(region.Contains(P(0, 0)), ());
121 TEST(region.Contains(P(3, 7)), ());
122 TEST(region.Contains(P(1, 2)), ());
123 TEST(region.Contains(P(1, 1)), ());
124 TEST(!region.Contains(P(6, 2)), ());
125 TEST(!region.Contains(P(3, 5)), ());
126 TEST(!region.Contains(P(5, 8)), ());
127 region.ForEachPoint(checker);
128}
129
130template <class Point>

Callers

nothing calls this directly

Calls 6

TestContainsRectangularFunction · 0.85
TESTFunction · 0.85
AssignMethod · 0.45
GetRectMethod · 0.45
ContainsMethod · 0.45
ForEachPointMethod · 0.45

Tested by

no test coverage detected