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

Function UNIT_TEST

libs/geometry/geometry_tests/intersection_score_tests.cpp:12–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <vector>
11
12UNIT_TEST(IntersectionScore_PointsToPolygon)
13{
14 {
15 m2::RectD rectD = {0, 0, 10, 10};
16 m2::AnyRectD const anyRect1(rectD);
17 rectD = {0, 0, 10, 9};
18 m2::AnyRectD const anyRect2(rectD);
19
20 m2::AnyRectD::Corners corners1;
21 anyRect1.GetGlobalPoints(corners1);
22
23 m2::AnyRectD::Corners corners2;
24 anyRect2.GetGlobalPoints(corners2);
25
26 auto const score = geometry::GetIntersectionScoreForPoints(corners1, corners2);
27
28 TEST(AlmostEqualAbs(score, 0.9, 1e-10), ());
29 }
30 {
31 m2::RectD rectD = {0, 0, 10, 10};
32 m2::AnyRectD const anyRect1(rectD);
33 rectD = {10, 10, 20, 20};
34 m2::AnyRectD const anyRect2(rectD);
35
36 m2::AnyRectD::Corners corners1;
37 anyRect1.GetGlobalPoints(corners1);
38
39 m2::AnyRectD::Corners corners2;
40 anyRect2.GetGlobalPoints(corners2);
41
42 auto const score = geometry::GetIntersectionScoreForPoints(corners1, corners2);
43
44 TEST(AlmostEqualAbs(score, 0.0, 1e-10), ());
45 }
46 {
47 m2::RectD rectD = {0, 0, 10, 10};
48 m2::AnyRectD const anyRect1(rectD);
49 m2::AnyRectD::Corners corners1;
50 anyRect1.GetGlobalPoints(corners1);
51
52 // Backward
53 m2::AnyRectD::Corners corners2 = {m2::PointD{10.0, 10.0}, {10.0, 0.0}, {0.0, 0.0}, {0.0, 10.0}};
54 auto const score = geometry::GetIntersectionScoreForPoints(corners1, corners2);
55
56 TEST(AlmostEqualAbs(score, 1.0, 1e-10), ());
57 }
58}
59
60UNIT_TEST(IntersectionScore_TrianglesToPolygon)
61{

Callers

nothing calls this directly

Calls 5

TESTFunction · 0.85
GetGlobalPointsMethod · 0.80
AlmostEqualAbsFunction · 0.50

Tested by

no test coverage detected