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

Function TEST

tests/cpp/types/Route_test.cpp:10–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "fields2cover/types.h"
9
10TEST(fields2cover_types_route, init) {
11 EXPECT_TRUE(F2CRoute().asLineString().isEmpty());
12 F2CRoute route;
13
14 EXPECT_EQ(route.startPoint(), F2CPoint());
15 route.addConnection(F2CMultiPoint({F2CPoint(-2, -1), F2CPoint(0, -1), F2CPoint(0, 0)}));
16 EXPECT_EQ(route.getLastConnection().size(), 3);
17 EXPECT_EQ(route.startPoint(), F2CPoint(-2, -1));
18 F2CSwaths swaths1;
19 swaths1.emplace_back(F2CLineString({F2CPoint(0, 0), F2CPoint(1, 0)}), 4);
20 swaths1.emplace_back(F2CLineString({F2CPoint(1, 1), F2CPoint(0, 1)}), 4);
21 route.addSwaths(swaths1);
22 EXPECT_EQ(route.getLastSwaths().size(), 2);
23 route.addConnection(F2CMultiPoint({F2CPoint(0, 1), F2CPoint(0, 2)}));
24 EXPECT_EQ(route.getLastConnection().size(), 2);
25 F2CSwaths swaths2;
26 swaths2.emplace_back(F2CLineString({F2CPoint(0, 2), F2CPoint(1, 2)}), 6);
27 swaths2.emplace_back(F2CLineString({F2CPoint(1, 3), F2CPoint(0, 3)}), 6);
28 swaths2.emplace_back(F2CLineString({F2CPoint(0, 4), F2CPoint(1, 4)}), 6);
29 swaths2.emplace_back(F2CLineString({F2CPoint(1, 5), F2CPoint(0, 5)}), 6);
30 route.addSwaths(swaths2);
31
32 const F2CRoute c_route {route};
33 EXPECT_EQ(c_route.getLastSwaths().size(), 4);
34 EXPECT_EQ(c_route.getLastConnection().size(), 2);
35
36 route.addConnection();
37 EXPECT_FALSE(route.isEmpty());
38 EXPECT_FALSE(route.asLineString().isEmpty());
39 EXPECT_EQ(route.sizeVectorSwaths(), 2);
40 EXPECT_EQ(route.sizeConnections(), 3);
41 EXPECT_EQ(route.asLineString().length(), 14);
42 EXPECT_EQ(route.length(), 14);
43 EXPECT_EQ(route.clone().length(), 14);
44 EXPECT_EQ(route.getSwaths(0).size(), 2);
45 EXPECT_EQ(route.getSwaths(1).size(), 4);
46
47 route.addConnection(F2CMultiPoint({F2CPoint(0, 5), F2CPoint(0, 6)}));
48 route.addConnection(F2CMultiPoint({F2CPoint(0, 8), F2CPoint(5, 8)}));
49 route.addConnection(F2CMultiPoint({F2CPoint(5, 10), F2CPoint(10, 10)}));
50 EXPECT_EQ(route.sizeVectorSwaths(), 2);
51 EXPECT_EQ(route.sizeConnections(), 3);
52 F2CSwaths swaths3;
53 swaths3.emplace_back(F2CLineString({F2CPoint(20, 20), F2CPoint(21, 20)}), 6);
54
55 route.addConnectedSwaths(F2CMultiPoint({F2CPoint(10, 10), F2CPoint(20, 10)}), swaths3);
56 EXPECT_EQ(route.sizeVectorSwaths(), 3);
57 EXPECT_EQ(route.sizeConnections(), 3);
58 EXPECT_EQ(route.length(), 50);
59
60 EXPECT_EQ(route.getConnection(0).size(), 3);
61 EXPECT_EQ(route.getSwaths(0).size(), 2);
62 EXPECT_EQ(route.getConnection(1).size(), 2);
63 EXPECT_EQ(route.getSwaths(1).size(), 4);
64 EXPECT_EQ(route.getConnection(2).size(), 8);
65 EXPECT_EQ(route.getSwaths(2).size(), 1);
66
67 EXPECT_EQ(route.getLastConnection().size(), 8);

Callers

nothing calls this directly

Calls 15

asLineStringMethod · 0.80
addConnectionMethod · 0.80
addSwathsMethod · 0.80
sizeVectorSwathsMethod · 0.80
sizeConnectionsMethod · 0.80
addConnectedSwathsMethod · 0.80
backMethod · 0.80
getPathMethod · 0.80
setPathMethod · 0.80
isEmptyMethod · 0.45
startPointMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected