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

Function UNIT_TEST

libs/geometry/geometry_tests/region2d_binary_op_test.cpp:16–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using R = m2::RegionI;
15
16UNIT_TEST(RegionIntersect_Smoke)
17{
18 {
19 P arr1[] = {P(-2, 1), P(2, 1), P(2, -1), P(-2, -1)};
20 P arr2[] = {P(-1, 2), P(1, 2), P(1, -2), P(-1, -2)};
21
22 R r1, r2;
23 r1.Assign(arr1, arr1 + ARRAY_SIZE(arr1));
24 r2.Assign(arr2, arr2 + ARRAY_SIZE(arr2));
25
26 vector<R> res;
27 m2::IntersectRegions(r1, r2, res);
28
29 TEST_EQUAL(res.size(), 1, ());
30 TEST_EQUAL(res[0].GetRect(), m2::RectI(-1, -1, 1, 1), ());
31 }
32
33 {
34 P arr1[] = {P(0, 0), P(1, 1), P(2, 0)};
35 P arr2[] = {P(0, 0), P(1, -1), P(2, 0)};
36
37 R r1, r2;
38 r1.Assign(arr1, arr1 + ARRAY_SIZE(arr1));
39 r2.Assign(arr2, arr2 + ARRAY_SIZE(arr2));
40
41 vector<R> res;
42 m2::IntersectRegions(r1, r2, res);
43
44 TEST_EQUAL(res.size(), 0, ());
45 }
46
47 {
48 P arr1[] = {P(-10, -10), P(10, -10), P(10, 10), P(-10, 10)};
49 P arr2[] = {P(-5, -5), P(5, -5), P(5, 5), P(-5, 5)};
50
51 R r1, r2;
52 r1.Assign(arr1, arr1 + ARRAY_SIZE(arr1));
53 r2.Assign(arr2, arr2 + ARRAY_SIZE(arr2));
54
55 vector<R> res;
56 res.push_back(r1); // do some smoke
57 m2::IntersectRegions(r1, r2, res);
58
59 TEST_EQUAL(res.size(), 2, ());
60 TEST_EQUAL(res[1].GetRect(), m2::RectI(-5, -5, 5, 5), ());
61 }
62}
63
64UNIT_TEST(RegionDifference_Smoke)
65{

Callers

nothing calls this directly

Calls 9

IntersectRegionsFunction · 0.85
DiffRegionsFunction · 0.85
AddRegionFunction · 0.85
CalculateAreaMethod · 0.80
AreaFunction · 0.50
AssignMethod · 0.45
sizeMethod · 0.45
GetRectMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected