| 9 | #include "fields2cover/objectives/rp_obj/direct_dist_path_obj.h" |
| 10 | |
| 11 | TEST(fields2cover_obj_direct_dist_path_obj, computeCost_cost) { |
| 12 | F2CSwath swath1(F2CLineString({F2CPoint(0.0, 1.0), F2CPoint(4.0, 1.0)})); |
| 13 | F2CSwath swath2(F2CLineString({F2CPoint(4.0, 3.0), F2CPoint(0.0, 3.0)})); |
| 14 | F2CSwath swath3(F2CLineString({F2CPoint(0.0, 0.0), F2CPoint(1.0, 1.0)})); |
| 15 | |
| 16 | auto createRoute = [](const F2CSwaths& s) { |
| 17 | F2CRoute route; |
| 18 | route.addConnection(); |
| 19 | route.addSwaths(s); |
| 20 | route.addConnection(); |
| 21 | return route; |
| 22 | }; |
| 23 | |
| 24 | F2CSwaths swaths1 {swath1}; |
| 25 | F2CSwaths swaths2 {swath2}; |
| 26 | F2CSwaths swaths4 {swath1,swath2,swath1,swath2}; |
| 27 | |
| 28 | auto r1 = createRoute(swaths1); |
| 29 | auto r2 = createRoute(swaths2); |
| 30 | auto r4 = createRoute(swaths4); |
| 31 | |
| 32 | f2c::obj::DirectDistPathObj length; |
| 33 | |
| 34 | F2CPoint p1(0,0), p2(4,0); |
| 35 | |
| 36 | EXPECT_EQ(length.computeCost(p1, p2), 4.0); |
| 37 | |
| 38 | std::vector<F2CPoint> ps1 {p1, p2}; |
| 39 | F2CMultiPoint ps2; |
| 40 | ps2.addGeometry(p1); |
| 41 | ps2.addGeometry(p2); |
| 42 | |
| 43 | EXPECT_EQ(length.computeCost(ps1), 4.0); |
| 44 | EXPECT_EQ(length.computeCost(ps2), 4.0); |
| 45 | EXPECT_EQ(length.computeCost(p1, p2, 0.0), 4.0); |
| 46 | EXPECT_EQ(length.computeCost(p1, 0.0, p2), 4.0); |
| 47 | EXPECT_EQ(length.computeCost(p1, 0.0, p2, 0.0), 4.0); |
| 48 | EXPECT_EQ(length.computeCost(p1, swath2), 5.0); |
| 49 | EXPECT_EQ(length.computeCost(swath2, p1), 3.0); |
| 50 | EXPECT_EQ(length.computeCost(p1, 0.0, swath2), 5.0); |
| 51 | EXPECT_EQ(length.computeCost(swath2, p1, 0.0), 3.0); |
| 52 | |
| 53 | EXPECT_EQ(length.computeCost(swath2, ps2), 3.0); |
| 54 | EXPECT_EQ(length.computeCost(swaths2, ps2), 3.0); |
| 55 | EXPECT_EQ(length.computeCost(ps2, swath2), 3.0); |
| 56 | EXPECT_EQ(length.computeCost(ps2, swaths2), 3.0); |
| 57 | |
| 58 | EXPECT_EQ(length.computeCost(swath2), 4.0); |
| 59 | EXPECT_EQ(length.computeCost(swaths4), 22.0); |
| 60 | |
| 61 | EXPECT_EQ(length.computeCost(F2CMultiPoint(), swath2), 0.0); |
| 62 | EXPECT_EQ(length.computeCost(swath2, F2CMultiPoint()), 0.0); |
| 63 | |
| 64 | EXPECT_EQ(length.computeCost(r1), 4.0); |
| 65 | EXPECT_EQ(length.computeCostWithMinimizingSign(r1), length.computeCost(r1)); |
| 66 | EXPECT_EQ(length.computeCost(r2), 4.0); |
| 67 | EXPECT_EQ(length.computeCostWithMinimizingSign(r2), length.computeCost(r2)); |
| 68 | EXPECT_EQ(length.computeCost(r4), 22.0); |
nothing calls this directly
no test coverage detected