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

Function TEST

tests/cpp/types/Cells_test.cpp:10–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "fields2cover/types.h"
9
10TEST(fields2cover_types_cells, constructor) {
11 F2CLinearRing ring1{
12 F2CPoint(0,0), F2CPoint(1,0),F2CPoint(1, 1),F2CPoint(0, 1), F2CPoint(0, 0)};
13 F2CCell cell {ring1};
14 F2CCells cells;
15 EXPECT_EQ(cells.size(), 0);
16 cells.addGeometry(cell);
17 const F2CCells cells_clone {cells.get()};
18
19 EXPECT_EQ(cells.area(), 1);
20 EXPECT_EQ(cells_clone.area(), 1);
21 EXPECT_EQ(cells_clone.getGeometry(0).area(), 1);
22
23
24 auto ring2 = ring1.clone();
25 ring2 *= 2.0;
26 auto ring3 = ring1 + F2CPoint(0.5, 0.5);
27 F2CCell cell2;
28 EXPECT_EQ(cell2.area(), 0);
29 cells.addGeometry(cell2);
30 cells.addRing(1, ring2);
31 cells.addRing(1, ring3);
32 EXPECT_EQ(cells.getInteriorRing(1, 0).length(), 4);
33
34 OGRGeometryCollection gc;
35 F2CCells empty_cells{&gc};
36 EXPECT_EQ(empty_cells.size(), 0);
37
38 F2CCell error_cell;
39 EXPECT_THROW(cells.getGeometry(100, error_cell), std::out_of_range);
40 EXPECT_THROW(cells_clone.getGeometry(100, error_cell), std::out_of_range);
41 EXPECT_THROW(cells.getGeometry(100), std::out_of_range);
42 EXPECT_THROW(cells_clone.getGeometry(100), std::out_of_range);
43}
44
45TEST(fields2cover_types_cells, difference) {
46 F2CCell cell1, cell2;

Callers

nothing calls this directly

Calls 15

getMethod · 0.80
differenceMethod · 0.80
unionOpMethod · 0.80
getCellWherePointMethod · 0.80
splitByLineMethod · 0.80
sizeMethod · 0.45
addGeometryMethod · 0.45
areaMethod · 0.45
getGeometryMethod · 0.45
cloneMethod · 0.45
addRingMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected