MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / test

Function test

code/geometry/polygon.test.cpp:10–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10void test() {
11 /* Field testing: Kattis pointinpolygon, Kattis forest, Kattis polygongame, UVa 11030, UVa 634 */
12
13 polygon pts;
14 pts.push_back(point(1, 1));
15 pts.push_back(point(1, 4));
16 pts.push_back(point(4, 4));
17 pts.push_back(point(4, 1));
18
19 assert_nearly_equal(-9.0, polygon_area_signed(pts));
20 assert_nearly_equal(9.0, polygon_area(pts));
21
22 reverse(pts.begin(), pts.end());
23
24 assert_nearly_equal(9.0, polygon_area_signed(pts));
25 assert_nearly_equal(9.0, polygon_area(pts));
26
27 pts.clear();
28 pts.push_back(point(1, 1));
29 pts.push_back(point(1, 4));
30 pts.push_back(point(2, 2));
31 pts.push_back(point(4, 1));
32
33 assert_nearly_equal(-3.0, polygon_area_signed(pts));
34 assert_nearly_equal(3.0, polygon_area(pts));
35
36}
37// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 6

polygon_area_signedFunction · 0.85
polygon_areaFunction · 0.85
push_backMethod · 0.80
pointClass · 0.70
assert_nearly_equalFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected