MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / TEST

Function TEST

source/test/poly_test.cpp:8–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace Star;
7
8TEST(PolyTest, ConvexHull) {
9 PolyF::VertexList inputVertexes;
10 for (unsigned i = 0; i < 1000; ++i) {
11 float angle = Random::randf() * 2 * Constants::pi;
12 inputVertexes.append({sin(angle), cos(angle)});
13 }
14
15 PolyF convex = PolyF::convexHull(inputVertexes);
16
17 PolyF::VertexList testVertexes;
18 for (unsigned i = 0; i < 1000; ++i) {
19 float angle = Random::randf() * 2 * Constants::pi;
20 testVertexes.append({sin(angle) * 0.75f, cos(angle) * 0.75f});
21 }
22
23 for (auto const& vertex : testVertexes)
24 EXPECT_TRUE(convex.contains(vertex * 0.75f));
25}
26
27TEST(PolyTest, Distance) {
28 PolyF square = {{-1.0f, -1.0f}, {1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}};

Callers

nothing calls this directly

Calls 9

randfFunction · 0.85
vmagFunction · 0.85
lineIntersectionMethod · 0.80
convexAreaMethod · 0.80
deduplicateVertexesMethod · 0.80
sidesMethod · 0.80
appendMethod · 0.45
containsMethod · 0.45
distanceMethod · 0.45

Tested by

no test coverage detected