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

Function TEST

tests/cpp/types/SwathsByCells_test.cpp:11–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "fields2cover/types.h"
10
11TEST(fields2cover_types_swathsByCells, init) {
12 const int n = 5;
13
14 F2CSwaths swaths;
15 std::vector<F2CSwaths> v_swaths;
16 for (int i = n; i >= 1; --i) {
17 swaths.emplace_back(F2CLineString({F2CPoint(i, i), F2CPoint(i, i + 1)}), i, i);
18 }
19 v_swaths.push_back(swaths);
20 v_swaths.push_back(swaths);
21 F2CSwathsByCells swaths_by_cells1 {swaths};
22 F2CSwathsByCells swaths_by_cells2 {v_swaths};
23 EXPECT_EQ(swaths_by_cells1.size(), 1);
24 EXPECT_EQ(swaths_by_cells2.size(), 2);
25 EXPECT_EQ(swaths_by_cells1[0].size(), n);
26 EXPECT_EQ(swaths_by_cells2[0].size(), n);
27
28 swaths_by_cells1.emplace_back(swaths);
29 swaths_by_cells1.emplace_back(swaths);
30 swaths_by_cells2.push_back(swaths);
31 EXPECT_EQ(swaths_by_cells1.size(), 3);
32 EXPECT_EQ(swaths_by_cells2.size(), 3);
33 EXPECT_EQ(swaths_by_cells1[0].size(), n);
34 EXPECT_EQ(swaths_by_cells1[1].size(), n);
35 EXPECT_EQ(swaths_by_cells2[0].size(), n);
36 EXPECT_EQ(swaths_by_cells2[1].size(), n);
37
38 const auto sbc_const = swaths_by_cells2.clone();
39
40 int j = 0;
41 for (int i = n; i >= 1; --i) {
42 EXPECT_EQ(swaths_by_cells1[0][j], swaths_by_cells2[0][j]);
43 EXPECT_EQ(swaths_by_cells1[0][j].getId(), i);
44 EXPECT_EQ(swaths_by_cells2[0][j].getId(), i);
45 EXPECT_EQ(swaths_by_cells1.at(0)[j].getWidth(), i);
46 EXPECT_EQ(swaths_by_cells2.at(0)[j].getWidth(), i);
47 EXPECT_EQ(sbc_const.at(0)[j].getWidth(), i);
48 EXPECT_EQ(swaths_by_cells1.back()[j].getWidth(), i);
49 EXPECT_EQ(swaths_by_cells2.back()[j].getWidth(), i);
50 EXPECT_EQ(sbc_const.back()[j].getWidth(), i);
51 ++j;
52 }
53
54 for (size_t i = 0; i < sbc_const.sizeTotal(); ++i) {
55 EXPECT_EQ(sbc_const.getSwath(i).getPath().startPoint(),
56 swaths_by_cells2.getSwath(i).getPath().startPoint());
57 EXPECT_EQ(sbc_const.getSwath(i).getPath().endPoint(),
58 swaths_by_cells2.getSwath(i).getPath().endPoint());
59 }
60}
61
62TEST(fields2cover_types_swathsByCells, reverse) {
63 F2CSwaths swaths1;

Callers

nothing calls this directly

Calls 13

backMethod · 0.80
sizeTotalMethod · 0.80
getPathMethod · 0.80
emplace_backMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
cloneMethod · 0.45
getIdMethod · 0.45
getWidthMethod · 0.45
atMethod · 0.45
startPointMethod · 0.45
endPointMethod · 0.45

Tested by

no test coverage detected