8 #ifndef SWATH_GENERATOR_CHECKER_HPP_
9 #define SWATH_GENERATOR_CHECKER_HPP_
11 #include <gtest/gtest.h>
17 const F2CCell& poly,
double swath_width = 1.0,
int checks = 100) {
20 return testing::AssertionFailure() <<
21 "Error 2001: No swaths were generated.";
22 }
else if (
swaths.size() > poly.
area() / (swath_width * swath_width)) {
23 return testing::AssertionFailure() <<
24 "Error 2002: " <<
swaths.size() <<
" swaths were generated." <<
25 "Expected less than " << poly.
area() / (swath_width * swath_width) <<
29 for(
int i = 0; i < checks; ++i) {
30 double rand_ang =
rand.getAngleRandom();
32 if (
obj.computeCostWithMinimizingSign(
swaths) >
33 obj.computeCostWithMinimizingSign(swaths2)) {
34 return testing::AssertionFailure() <<
35 "Error 2003: Cost (signed) of the optimal angle is " <<
36 obj.computeCostWithMinimizingSign(
swaths) <<
37 ", but the cost (signed) of a non-optimal angle (" <<
38 rand_ang <<
") is " <<
39 obj.computeCostWithMinimizingSign(swaths2) <<
".";
40 }
else if (
swaths.size() > poly.
area() / (swath_width * swath_width)) {
41 return testing::AssertionFailure() <<
"Error 2004: " << swaths2.size() <<
42 " swaths were generated with angle " << rand_ang <<
43 "Expected less than " << poly.
area() / (swath_width * swath_width) <<
47 return testing::AssertionSuccess();
52 const F2CCells& poly,
double swath_width = 1.0,
int checks = 100) {
54 EXPECT_EQ(swaths_by_cells.size(), poly.
size());
56 for (
auto&&
swaths : swaths_by_cells) {
58 return testing::AssertionFailure() <<
59 "Error 2001: No swaths were generated.";
60 }
else if (
swaths.size() > poly.
area() / (swath_width * swath_width)) {
61 return testing::AssertionFailure() <<
62 "Error 2002: " <<
swaths.size() <<
" swaths were generated." <<
63 "Expected less than " << poly.
area() / (swath_width * swath_width) <<
68 for(
int i = 0; i < checks; ++i) {
69 double rand_ang =
rand.getAngleRandom();
70 auto swaths_by_cells2 = sw_gen.
generateSwaths(rand_ang, swath_width, poly);
71 EXPECT_EQ(swaths_by_cells2.size(), poly.
size());
72 for (
int j = 0; j < swaths_by_cells2.size(); ++j) {
73 if (
obj.computeCostWithMinimizingSign(swaths_by_cells[j]) >
74 obj.computeCostWithMinimizingSign(swaths_by_cells2[j])) {
75 return testing::AssertionFailure() <<
76 "Error 2003: Cost (signed) of the optimal angle is " <<
77 obj.computeCostWithMinimizingSign(swaths_by_cells[j]) <<
78 ", but the cost (signed) of a non-optimal angle (" <<
79 rand_ang <<
") is " <<
80 obj.computeCostWithMinimizingSign(swaths_by_cells2[j]) <<
".";
81 }
else if (swaths_by_cells[j].size() > poly.
area() / (swath_width * swath_width)) {
82 return testing::AssertionFailure() <<
"Error 2004: " << swaths_by_cells2[j].size() <<
83 " swaths were generated with angle " << rand_ang <<
84 "Expected less than " << poly.
area() / (swath_width * swath_width) <<
89 return testing::AssertionSuccess();
92 #endif // SWATH_GENERATOR_CHECKER_HPP_