55using namespace packingsolver ;
66using namespace packingsolver ::irregular;
77
8- struct ShapeElementLengthTestParams
8+ struct IrregularShapeElementLengthTestParams
99{
1010 ShapeElement element;
1111 LengthDbl expected_length;
1212};
1313
14- class IrregularShapeElementLengthTest : public testing ::TestWithParam<ShapeElementLengthTestParams > { };
14+ class IrregularShapeElementLengthTest : public testing ::TestWithParam<IrregularShapeElementLengthTestParams > { };
1515
16- TEST_P (IrregularShapeElementLengthTest, ShapeElementLength )
16+ TEST_P (IrregularShapeElementLengthTest, IrregularShapeElementLength )
1717{
18- ShapeElementLengthTestParams test_params = GetParam ();
18+ IrregularShapeElementLengthTestParams test_params = GetParam ();
1919 EXPECT_TRUE (equal (test_params.element .length (), test_params.expected_length ));
2020}
2121
2222INSTANTIATE_TEST_SUITE_P (
2323 Irregular,
2424 IrregularShapeElementLengthTest,
25- testing::ValuesIn (std::vector<ShapeElementLengthTestParams >{
25+ testing::ValuesIn (std::vector<IrregularShapeElementLengthTestParams >{
2626 {build_shape ({{0 , 0 }, {0 , 1 }}, true ).elements .front (), 1 },
2727 {build_shape ({{1 , 0 }, {0 , 0 , 1 }, {0 , 1 }}, true ).elements .front (), M_PI / 2 },
2828 {build_shape ({{1 , 0 }, {0 , 0 , -1 }, {0 , -1 }}, true ).elements .front (), M_PI / 2 },
2929 }));
3030
3131
32+ struct IrregularShapeElementMinMaxTestParams
33+ {
34+ ShapeElement element;
35+ LengthDbl expected_x_min;
36+ LengthDbl expected_y_min;
37+ LengthDbl expected_x_max;
38+ LengthDbl expected_y_max;
39+ };
40+
41+ class IrregularShapeElementMinMaxTest : public testing ::TestWithParam<IrregularShapeElementMinMaxTestParams> { };
42+
43+ TEST_P (IrregularShapeElementMinMaxTest, IrregularShapeElementMinMax)
44+ {
45+ IrregularShapeElementMinMaxTestParams test_params = GetParam ();
46+ std::cout << " element " << test_params.element .to_string () << std::endl;
47+ std::cout << " expected x_min " << test_params.expected_x_min
48+ << " y_min " << test_params.expected_y_min
49+ << " x_max " << test_params.expected_x_max
50+ << " y_max " << test_params.expected_y_max << std::endl;
51+ auto mm = test_params.element .min_max ();
52+ std::cout << " x_min " << mm.first .x
53+ << " y_min " << mm.first .y
54+ << " x_max " << mm.second .x
55+ << " y_max " << mm.second .y << std::endl;
56+ EXPECT_TRUE (equal (mm.first .x , test_params.expected_x_min ));
57+ EXPECT_TRUE (equal (mm.second .x , test_params.expected_x_max ));
58+ EXPECT_TRUE (equal (mm.first .y , test_params.expected_y_min ));
59+ EXPECT_TRUE (equal (mm.second .y , test_params.expected_y_max ));
60+ }
61+
62+ INSTANTIATE_TEST_SUITE_P (
63+ Irregular,
64+ IrregularShapeElementMinMaxTest,
65+ testing::ValuesIn (std::vector<IrregularShapeElementMinMaxTestParams>{
66+ {build_shape ({{0 , 1 }, {2 , 3 }}, true ).elements .front (), 0 , 1 , 2 , 3 },
67+ {build_shape ({{1 , 0 }, {0 , 0 , 1 }, {-1 , 0 }}, true ).elements .front (), -1 , 0 , 1 , 1 },
68+ {build_shape ({{1 , 0 }, {0 , 0 , -1 }, {-1 , 0 }}, true ).elements .front (), -1 , -1 , 1 , 0 },
69+
70+ {build_shape ({{0 , 1 }, {0 , 0 , 1 }, {1 , 0 }}, true ).elements .front (), -1 , -1 , 1 , 1 },
71+ {build_shape ({{-1 , 0 }, {0 , 0 , 1 }, {0 , 1 }}, true ).elements .front (), -1 , -1 , 1 , 1 },
72+ {build_shape ({{0 , -1 }, {0 , 0 , 1 }, {-1 , 0 }}, true ).elements .front (), -1 , -1 , 1 , 1 },
73+ {build_shape ({{1 , 0 }, {0 , 0 , 1 }, {0 , -1 }}, true ).elements .front (), -1 , -1 , 1 , 1 },
74+ }));
75+
76+
3277struct CleanShapeTestParams
3378{
3479 Shape shape;
@@ -61,19 +106,19 @@ INSTANTIATE_TEST_SUITE_P(
61106 }}));
62107
63108
64- struct ShapeContainsTestParams
109+ struct IrregularShapeContainsTestParams
65110{
66111 Shape shape;
67112 Point point;
68113 bool strict;
69114 bool expected_contained;
70115};
71116
72- class IrregularShapeContainsTest : public testing ::TestWithParam<ShapeContainsTestParams > { };
117+ class IrregularShapeContainsTest : public testing ::TestWithParam<IrregularShapeContainsTestParams > { };
73118
74- TEST_P (IrregularShapeContainsTest, ShapeContains )
119+ TEST_P (IrregularShapeContainsTest, IrregularShapeContains )
75120{
76- ShapeContainsTestParams test_params = GetParam ();
121+ IrregularShapeContainsTestParams test_params = GetParam ();
77122 std::cout << " shape" << std::endl;
78123 std::cout << test_params.shape .to_string (0 ) << std::endl;
79124 std::cout << " point " << test_params.point .to_string () << std::endl;
@@ -91,7 +136,7 @@ TEST_P(IrregularShapeContainsTest, ShapeContains)
91136INSTANTIATE_TEST_SUITE_P (
92137 Irregular,
93138 IrregularShapeContainsTest,
94- testing::ValuesIn (std::vector<ShapeContainsTestParams >{
139+ testing::ValuesIn (std::vector<IrregularShapeContainsTestParams >{
95140 { // Point oustide of polygon
96141 build_shape ({{0 , 0 }, {1 , 0 }, {1 , 1 }, {0 , 1 }}),
97142 {2 , 2 },
@@ -140,19 +185,19 @@ INSTANTIATE_TEST_SUITE_P(
140185 }}));
141186
142187
143- struct ApproximateCircularArcByLineSegmentsTestParams
188+ struct IrregularApproximateCircularArcByLineSegmentsTestParams
144189{
145190 ShapeElement circular_arc;
146191 ElementPos number_of_line_segments;
147192 bool outer;
148193 std::vector<ShapeElement> expected_line_segments;
149194};
150195
151- class IrregularApproximateCircularArcByLineSegmentsTest : public testing ::TestWithParam<ApproximateCircularArcByLineSegmentsTestParams > { };
196+ class IrregularApproximateCircularArcByLineSegmentsTest : public testing ::TestWithParam<IrregularApproximateCircularArcByLineSegmentsTestParams > { };
152197
153- TEST_P (IrregularApproximateCircularArcByLineSegmentsTest, ApproximateCircularArcByLineSegments )
198+ TEST_P (IrregularApproximateCircularArcByLineSegmentsTest, IrregularApproximateCircularArcByLineSegments )
154199{
155- ApproximateCircularArcByLineSegmentsTestParams test_params = GetParam ();
200+ IrregularApproximateCircularArcByLineSegmentsTestParams test_params = GetParam ();
156201 std::cout << " circular_arc" << std::endl;
157202 std::cout << test_params.circular_arc .to_string () << std::endl;
158203 std::cout << " expected_line_segments" << std::endl;
@@ -176,7 +221,7 @@ TEST_P(IrregularApproximateCircularArcByLineSegmentsTest, ApproximateCircularArc
176221INSTANTIATE_TEST_SUITE_P (
177222 Irregular,
178223 IrregularApproximateCircularArcByLineSegmentsTest,
179- testing::ValuesIn (std::vector<ApproximateCircularArcByLineSegmentsTestParams >{
224+ testing::ValuesIn (std::vector<IrregularApproximateCircularArcByLineSegmentsTestParams >{
180225 {
181226 build_shape ({{1 , 0 }, {0 , 0 , 1 }, {0 , 1 }}, true ).elements .front (),
182227 1 ,
0 commit comments