diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 26e4d84..a5b5715 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,6 @@ include(GoogleTest) add_executable(Shape_shape_test) target_sources(Shape_shape_test PRIVATE - test_params.hpp trapezoid_test.cpp shape_test.cpp elements_intersections_test.cpp diff --git a/test/approximation_test.cpp b/test/approximation_test.cpp index 15b6ebc..97b1b3f 100644 --- a/test/approximation_test.cpp +++ b/test/approximation_test.cpp @@ -112,18 +112,6 @@ struct ApproximateShapeByLineSegmentsTestParams ShapeWithHoles expected_output; - static ApproximateShapeByLineSegmentsTestParams from_json( - nlohmann::basic_json<>& json_item) - { - ApproximateShapeByLineSegmentsTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.segment_length = json_item["segment_length"]; - test_params.outer = json_item["outer"]; - if (json_item.contains("expected_output")) - test_params.expected_output = ShapeWithHoles::from_json(json_item["expected_output"]); - return test_params; - } - static ApproximateShapeByLineSegmentsTestParams read_json( const std::string& file_path) { @@ -136,8 +124,13 @@ struct ApproximateShapeByLineSegmentsTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + ApproximateShapeByLineSegmentsTestParams test_params; test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.segment_length = json["segment_length"]; + test_params.outer = json["outer"]; + if (json.contains("expected_output")) + test_params.expected_output = ShapeWithHoles::from_json(json["expected_output"]); return test_params; } }; @@ -219,17 +212,6 @@ struct ApproximateByLineSegmentsTestParams ShapeWithHoles expected_output; - static ApproximateByLineSegmentsTestParams from_json( - nlohmann::basic_json<>& json_item) - { - ApproximateByLineSegmentsTestParams test_params; - test_params.shape_with_holes = ShapeWithHoles::from_json(json_item["shape_with_holes"]); - test_params.segment_length = json_item["segment_length"]; - if (json_item.contains("expected_output")) - test_params.expected_output = ShapeWithHoles::from_json(json_item["expected_output"]); - return test_params; - } - static ApproximateByLineSegmentsTestParams read_json( const std::string& file_path) { @@ -242,8 +224,12 @@ struct ApproximateByLineSegmentsTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + ApproximateByLineSegmentsTestParams test_params; test_params.name = file_path; + test_params.shape_with_holes = ShapeWithHoles::from_json(json["shape_with_holes"]); + test_params.segment_length = json["segment_length"]; + if (json.contains("expected_output")) + test_params.expected_output = ShapeWithHoles::from_json(json["expected_output"]); return test_params; } }; diff --git a/test/boolean_operations_test.cpp b/test/boolean_operations_test.cpp index c8ba012..bd1dc06 100644 --- a/test/boolean_operations_test.cpp +++ b/test/boolean_operations_test.cpp @@ -6,7 +6,10 @@ #include -#include "test_params.hpp" +#include +#include + +namespace fs = boost::filesystem; using namespace shape; @@ -17,17 +20,6 @@ struct FindHolesBridgesTestParams ShapeWithHoles shape; std::vector expected_output; - template - static FindHolesBridgesTestParams from_json( - basic_json& json_item) - { - FindHolesBridgesTestParams test_params; - test_params.shape = ShapeWithHoles::from_json(json_item["shape"]); - for (auto& json_element: json_item["expected_output"].items()) - test_params.expected_output.emplace_back(ShapeElement::from_json(json_element.value())); - return test_params; - } - static FindHolesBridgesTestParams read_json( const std::string& file_path) { @@ -40,7 +32,12 @@ struct FindHolesBridgesTestParams nlohmann::json json; file >> json; - return from_json(json); + FindHolesBridgesTestParams test_params; + test_params.name = file_path; + test_params.shape = ShapeWithHoles::from_json(json["shape"]); + for (auto& json_element: json["expected_output"].items()) + test_params.expected_output.emplace_back(ShapeElement::from_json(json_element.value())); + return test_params; } }; @@ -146,20 +143,31 @@ INSTANTIATE_TEST_SUITE_P( }); -struct ComputeBooleanUnionTestParams: TestParams +struct ComputeBooleanUnionTestParams { + std::string name; std::vector shapes; std::vector expected_output; - static ComputeBooleanUnionTestParams from_json( - nlohmann::basic_json<>& json_item) + static ComputeBooleanUnionTestParams read_json( + const std::string& file_path) { - ComputeBooleanUnionTestParams test_params = TestParams::from_json(json_item); - for (auto& json_shape: json_item["shapes"].items()) + std::ifstream file(file_path); + if (!file.good()) { + throw std::runtime_error( + FUNC_SIGNATURE + ": " + "unable to open file \"" + file_path + "\"."); + } + + nlohmann::json json; + file >> json; + ComputeBooleanUnionTestParams test_params; + test_params.name = file_path; + for (auto& json_shape: json["shapes"].items()) test_params.shapes.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - if (json_item.contains("expected_output")) - for (auto& json_shape: json_item["expected_output"].items()) + if (json.contains("expected_output")) + for (auto& json_shape: json["expected_output"].items()) test_params.expected_output.emplace_back(ShapeWithHoles::from_json(json_shape.value())); return test_params; } @@ -167,7 +175,7 @@ struct ComputeBooleanUnionTestParams: TestParams void PrintTo(const ComputeBooleanUnionTestParams& params, std::ostream* os) { - *os << "Testing " << params.name << " (" << params.description << ")...\n"; + *os << "Testing " << params.name << "...\n"; *os << "shapes\n"; for (const ShapeWithHoles& shape: params.shapes) *os << "- " << shape.to_string(2) << "\n"; @@ -206,22 +214,6 @@ TEST_P(ComputeBooleanUnionTest, ComputeBooleanUnion) Writer().add_shapes_with_holes(output).write_json("compute_union_output.json"); #endif - if (test_params.write_json || test_params.write_svg) { - std::string base_filename = "union_" + fs::path(test_params.name).filename().replace_extension("").string(); - - if (test_params.write_json) { - Writer().add_shapes_with_holes(test_params.shapes).write_json(base_filename + "_shapes.json"); - Writer().add_shapes_with_holes(test_params.expected_output).write_json(base_filename + "_expected_output.json"); - Writer().add_shapes_with_holes(output).write_json(base_filename + "_output.json"); - } - if (test_params.write_svg) { - Writer().add_shapes_with_holes(test_params.shapes).write_svg(base_filename + "_shapes.svg"); - Writer().add_shapes_with_holes(test_params.expected_output).write_svg(base_filename + "_expected_output.svg"); - Writer().add_shapes_with_holes(output).write_svg(base_filename + "_output.svg"); - } - - } - ASSERT_EQ(output.size(), test_params.expected_output.size()); for (const ShapeWithHoles& expected_shape: test_params.expected_output) { EXPECT_NE(std::find_if( @@ -235,25 +227,89 @@ TEST_P(ComputeBooleanUnionTest, ComputeBooleanUnion) INSTANTIATE_TEST_SUITE_P( Shape, ComputeBooleanUnionTest, - testing::ValuesIn(ComputeBooleanUnionTestParams::read_dir((fs::path("data") / "tests" / "boolean_operations" / "union").string())), + testing::ValuesIn(std::vector{ + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "000.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "001.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "002.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "003.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "004.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "005.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "006.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "007.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "008.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "009.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "010.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "011.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "012.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "013.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "014.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "015.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "016.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "017.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "018.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "019.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "020.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "021.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "022.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "023.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "024.json").string()), + ComputeBooleanUnionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "union" / "025.json").string()), + }), [](const testing::TestParamInfo& info) { return fs::path(info.param.name).stem().string(); }); -struct ComputeBooleanIntersectionTestParams: TestParams +struct ComputeBooleanIntersectionTestParams { + std::string name; std::vector shapes; std::vector expected_output; - static ComputeBooleanIntersectionTestParams from_json( - nlohmann::basic_json<>& json_item) + static ComputeBooleanIntersectionTestParams read_json( + const std::string& file_path) { - ComputeBooleanIntersectionTestParams test_params = TestParams::from_json(json_item); - for (auto& json_shape: json_item["shapes"].items()) + std::ifstream file(file_path); + if (!file.good()) { + throw std::runtime_error( + FUNC_SIGNATURE + ": " + "unable to open file \"" + file_path + "\"."); + } + + nlohmann::json json; + file >> json; + ComputeBooleanIntersectionTestParams test_params; + test_params.name = file_path; + for (auto& json_shape: json["shapes"].items()) test_params.shapes.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - for (auto& json_shape: json_item["expected_output"].items()) + for (auto& json_shape: json["expected_output"].items()) test_params.expected_output.emplace_back(ShapeWithHoles::from_json(json_shape.value())); return test_params; } @@ -261,7 +317,7 @@ struct ComputeBooleanIntersectionTestParams: TestParams{ + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "000.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "001.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "002.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "003.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "004.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "005.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "006.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "007.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "008.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "009.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "010.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "011.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "012.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "013.json").string()), + ComputeBooleanIntersectionTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "intersection" / "014.json").string()), + }), [](const testing::TestParamInfo& info) { return fs::path(info.param.name).stem().string(); }); -struct ComputeBooleanDifferenceTestParams : TestParams +struct ComputeBooleanDifferenceTestParams { + std::string name; std::vector shapes_1; std::vector shapes; std::vector expected_output; - static ComputeBooleanDifferenceTestParams from_json( - nlohmann::basic_json<>& json_item) + static ComputeBooleanDifferenceTestParams read_json( + const std::string& file_path) { - ComputeBooleanDifferenceTestParams test_params = TestParams::from_json(json_item); - for (auto& json_shape: json_item["shapes_1"].items()) + std::ifstream file(file_path); + if (!file.good()) { + throw std::runtime_error( + FUNC_SIGNATURE + ": " + "unable to open file \"" + file_path + "\"."); + } + + nlohmann::json json; + file >> json; + ComputeBooleanDifferenceTestParams test_params; + test_params.name = file_path; + for (auto& json_shape: json["shapes_1"].items()) test_params.shapes_1.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - for (auto& json_shape: json_item["shapes"].items()) + for (auto& json_shape: json["shapes"].items()) test_params.shapes.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - for (auto& json_shape: json_item["expected_output"].items()) + for (auto& json_shape: json["expected_output"].items()) test_params.expected_output.emplace_back(ShapeWithHoles::from_json(json_shape.value())); return test_params; } @@ -350,7 +432,7 @@ struct ComputeBooleanDifferenceTestParams : TestParams{ + ComputeBooleanDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "difference" / "000.json").string()), + ComputeBooleanDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "difference" / "001.json").string()), + ComputeBooleanDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "difference" / "002.json").string()), + ComputeBooleanDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "difference" / "003.json").string()), + ComputeBooleanDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "difference" / "004.json").string()), + ComputeBooleanDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "difference" / "005.json").string()), + }), [](const testing::TestParamInfo& info) { return fs::path(info.param.name).stem().string(); }); -struct ComputeBooleanSymmetricDifferenceTestParams : TestParams +struct ComputeBooleanSymmetricDifferenceTestParams { + std::string name; std::vector shapes_1; std::vector shapes_2; std::vector expected_output; - static ComputeBooleanSymmetricDifferenceTestParams from_json( - nlohmann::basic_json<>& json_item) + static ComputeBooleanSymmetricDifferenceTestParams read_json( + const std::string& file_path) { - ComputeBooleanSymmetricDifferenceTestParams test_params = TestParams::from_json(json_item); - for (auto& json_shape: json_item["shapes_1"].items()) + std::ifstream file(file_path); + if (!file.good()) { + throw std::runtime_error( + FUNC_SIGNATURE + ": " + "unable to open file \"" + file_path + "\"."); + } + + nlohmann::json json; + file >> json; + ComputeBooleanSymmetricDifferenceTestParams test_params; + test_params.name = file_path; + for (auto& json_shape: json["shapes_1"].items()) test_params.shapes_1.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - for (auto& json_shape: json_item["shapes_2"].items()) + for (auto& json_shape: json["shapes_2"].items()) test_params.shapes_2.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - for (auto& json_shape: json_item["expected_output"].items()) + for (auto& json_shape: json["expected_output"].items()) test_params.expected_output.emplace_back(ShapeWithHoles::from_json(json_shape.value())); return test_params; } @@ -433,7 +524,7 @@ struct ComputeBooleanSymmetricDifferenceTestParams : TestParams{ + ComputeBooleanSymmetricDifferenceTestParams::read_json( + (fs::path("data") / "tests" / "boolean_operations" / "symmetric_difference" / "000.json").string()), + }), [](const testing::TestParamInfo& info) { return fs::path(info.param.name).stem().string(); }); @@ -501,15 +579,6 @@ struct ExtractOutlineTestParams Shape expected_output; - static ExtractOutlineTestParams from_json( - nlohmann::basic_json<>& json_item) - { - ExtractOutlineTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.expected_output = Shape::from_json(json_item["expected_output"]); - return test_params; - } - static ExtractOutlineTestParams read_json( const std::string& file_path) { @@ -522,8 +591,10 @@ struct ExtractOutlineTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + ExtractOutlineTestParams test_params; test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.expected_output = Shape::from_json(json["expected_output"]); return test_params; } }; @@ -576,16 +647,6 @@ struct ExtractFacesTestParams std::vector expected_output; - static ExtractFacesTestParams from_json( - nlohmann::basic_json<>& json_item) - { - ExtractFacesTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - for (auto& json_shape: json_item["expected_output"].items()) - test_params.expected_output.emplace_back(Shape::from_json(json_shape.value())); - return test_params; - } - static ExtractFacesTestParams read_json( const std::string& file_path) { @@ -598,7 +659,12 @@ struct ExtractFacesTestParams nlohmann::json json; file >> json; - return from_json(json); + ExtractFacesTestParams test_params; + test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + for (auto& json_shape: json["expected_output"].items()) + test_params.expected_output.emplace_back(Shape::from_json(json_shape.value())); + return test_params; } }; @@ -670,16 +736,6 @@ struct BridgeTouchingHolesTestParams std::vector expected_output; - static BridgeTouchingHolesTestParams from_json( - nlohmann::basic_json<>& json_item) - { - BridgeTouchingHolesTestParams test_params; - test_params.shape = ShapeWithHoles::from_json(json_item["shape"]); - for (auto& json_shape: json_item["expected_output"].items()) - test_params.expected_output.emplace_back(ShapeWithHoles::from_json(json_shape.value())); - return test_params; - } - static BridgeTouchingHolesTestParams read_json( const std::string& file_path) { @@ -692,8 +748,11 @@ struct BridgeTouchingHolesTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + BridgeTouchingHolesTestParams test_params; test_params.name = file_path; + test_params.shape = ShapeWithHoles::from_json(json["shape"]); + for (auto& json_shape: json["expected_output"].items()) + test_params.expected_output.emplace_back(ShapeWithHoles::from_json(json_shape.value())); return test_params; } }; diff --git a/test/clean_test.cpp b/test/clean_test.cpp index a1ae2f3..f7dbbc8 100644 --- a/test/clean_test.cpp +++ b/test/clean_test.cpp @@ -60,16 +60,6 @@ struct CleanExtremeSlopesOuterTestParams ShapeWithHoles expected_output; - template - static CleanExtremeSlopesOuterTestParams from_json( - basic_json& json_item) - { - CleanExtremeSlopesOuterTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.expected_output = ShapeWithHoles::from_json(json_item["expected_output"]); - return test_params; - } - static CleanExtremeSlopesOuterTestParams read_json( const std::string& file_path) { @@ -82,8 +72,10 @@ struct CleanExtremeSlopesOuterTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + CleanExtremeSlopesOuterTestParams test_params; test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.expected_output = ShapeWithHoles::from_json(json["expected_output"]); return test_params; } }; diff --git a/test/elements_intersections_test.cpp b/test/elements_intersections_test.cpp index e9317da..bf3df2e 100644 --- a/test/elements_intersections_test.cpp +++ b/test/elements_intersections_test.cpp @@ -19,22 +19,6 @@ struct ComputeIntersectionsTestParams ShapeElement element_2; ShapeElementIntersectionsOutput expected_output; - template - static ComputeIntersectionsTestParams from_json( - basic_json& json_item) - { - ComputeIntersectionsTestParams test_params; - test_params.element_1 = ShapeElement::from_json(json_item["element_1"]); - test_params.element_2 = ShapeElement::from_json(json_item["element_2"]); - for (auto& json_element: json_item["expected_output"]["overlapping_parts"].items()) - test_params.expected_output.overlapping_parts.emplace_back(ShapeElement::from_json(json_element.value())); - for (auto& json_point: json_item["expected_output"]["improper_intersections"].items()) - test_params.expected_output.improper_intersections.emplace_back(Point::from_json(json_point.value())); - for (auto& json_point: json_item["expected_output"]["proper_intersections"].items()) - test_params.expected_output.proper_intersections.emplace_back(Point::from_json(json_point.value())); - return test_params; - } - static ComputeIntersectionsTestParams read_json( const std::string& file_path) { @@ -47,7 +31,16 @@ struct ComputeIntersectionsTestParams nlohmann::json json; file >> json; - return from_json(json); + ComputeIntersectionsTestParams test_params; + test_params.element_1 = ShapeElement::from_json(json["element_1"]); + test_params.element_2 = ShapeElement::from_json(json["element_2"]); + for (auto& json_element: json["expected_output"]["overlapping_parts"].items()) + test_params.expected_output.overlapping_parts.emplace_back(ShapeElement::from_json(json_element.value())); + for (auto& json_point: json["expected_output"]["improper_intersections"].items()) + test_params.expected_output.improper_intersections.emplace_back(Point::from_json(json_point.value())); + for (auto& json_point: json["expected_output"]["proper_intersections"].items()) + test_params.expected_output.proper_intersections.emplace_back(Point::from_json(json_point.value())); + return test_params; } }; diff --git a/test/offset_test.cpp b/test/offset_test.cpp index f0ab466..e4eed48 100644 --- a/test/offset_test.cpp +++ b/test/offset_test.cpp @@ -6,7 +6,10 @@ #include -#include "test_params.hpp" +#include +#include + +namespace fs = boost::filesystem; using namespace shape; @@ -19,17 +22,6 @@ struct InflateShapeTestParams ShapeWithHoles expected_output; - static InflateShapeTestParams from_json( - nlohmann::basic_json<>& json_item) - { - InflateShapeTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.offset = json_item["offset"]; - if (json_item.contains("expected_output")) - test_params.expected_output = ShapeWithHoles::from_json(json_item["expected_output"]); - return test_params; - } - static InflateShapeTestParams read_json( const std::string& file_path) { @@ -42,8 +34,12 @@ struct InflateShapeTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + InflateShapeTestParams test_params; test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.offset = json["offset"]; + if (json.contains("expected_output")) + test_params.expected_output = ShapeWithHoles::from_json(json["expected_output"]); return test_params; } }; @@ -173,28 +169,39 @@ INSTANTIATE_TEST_SUITE_P( }); -struct InflateShapeWithHolesTestParams: TestParams +struct InflateShapeWithHolesTestParams { + std::string name; ShapeWithHoles shape; LengthDbl offset = 0; ShapeWithHoles expected_output; - static InflateShapeWithHolesTestParams from_json( - nlohmann::basic_json<>& json_item) + static InflateShapeWithHolesTestParams read_json( + const std::string& file_path) { - InflateShapeWithHolesTestParams test_params = TestParams::from_json(json_item); - test_params.shape = ShapeWithHoles::from_json(json_item["shape"]); - test_params.offset = json_item["offset"]; - if (json_item.contains("expected_output")) - test_params.expected_output = ShapeWithHoles::from_json(json_item["expected_output"]); + std::ifstream file(file_path); + if (!file.good()) { + throw std::runtime_error( + FUNC_SIGNATURE + ": " + "unable to open file \"" + file_path + "\"."); + } + + nlohmann::json json; + file >> json; + InflateShapeWithHolesTestParams test_params; + test_params.name = file_path; + test_params.shape = ShapeWithHoles::from_json(json["shape"]); + test_params.offset = json["offset"]; + if (json.contains("expected_output")) + test_params.expected_output = ShapeWithHoles::from_json(json["expected_output"]); return test_params; } }; void PrintTo(const InflateShapeWithHolesTestParams& params, std::ostream* os) { - *os << "Testing " << params.name << " (" << params.description << ")...\n"; + *os << "Testing " << params.name << "...\n"; *os << "shape " << params.shape.to_string(0) << "\n"; *os << "offset " << params.offset << "\n"; *os << "expected_output " << params.expected_output.to_string(0) << "\n"; @@ -221,49 +228,89 @@ TEST_P(InflateShapeWithHolesTest, InflateShapeWithHoles) Writer().add_shape_with_holes(test_params.shape).add_shape_with_holes(output).write_json("inflate_output.json"); #endif - if (test_params.write_json || test_params.write_svg) { - std::string base_filename = "inflate_" + fs::path(test_params.name).filename().replace_extension("").string(); - - if (test_params.write_json) { - Writer().add_shape_with_holes(test_params.shape).write_json(base_filename + "_shapes.json"); - Writer().add_shape_with_holes(test_params.expected_output).write_json(base_filename + "_expected_output.json"); - Writer().add_shape_with_holes(output).write_json(base_filename + "_output.json"); - } - if (test_params.write_svg) { - Writer().add_shape_with_holes(test_params.shape).write_svg(base_filename + "_shapes.svg"); - Writer().add_shape_with_holes(test_params.expected_output).write_svg(base_filename + "_expected_output.svg"); - Writer().add_shape_with_holes(output).write_svg(base_filename + "_output.svg"); - } - } - EXPECT_TRUE(equal(output, test_params.expected_output)); } INSTANTIATE_TEST_SUITE_P( Shape, InflateShapeWithHolesTest, - testing::ValuesIn(InflateShapeWithHolesTestParams::read_dir((fs::path("data") / "tests" / "offset" / "inflate").string())), + testing::ValuesIn(std::vector{ + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "000.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "001.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "002.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "003.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "004.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "005.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "006.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "007.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "008.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "009.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "010.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "011.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "012.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "013.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "014.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "015.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "016.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "017.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "018.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "019.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "020.json").string()), + InflateShapeWithHolesTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "inflate" / "021.json").string()), + }), [](const testing::TestParamInfo& info) { return fs::path(info.param.name).stem().string(); }); -struct DeflateTestParams: TestParams +struct DeflateTestParams { + std::string name; Shape shape; LengthDbl offset = 0; std::vector expected_output; - static DeflateTestParams from_json( - nlohmann::basic_json<>& json_item) + static DeflateTestParams read_json( + const std::string& file_path) { - DeflateTestParams test_params = TestParams::from_json(json_item); - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.offset = json_item["offset"]; + std::ifstream file(file_path); + if (!file.good()) { + throw std::runtime_error( + FUNC_SIGNATURE + ": " + "unable to open file \"" + file_path + "\"."); + } - if (json_item.contains("expected_output")) - for (auto& json_shape: json_item["expected_output"].items()) + nlohmann::json json; + file >> json; + DeflateTestParams test_params; + test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.offset = json["offset"]; + if (json.contains("expected_output")) + for (auto& json_shape: json["expected_output"].items()) test_params.expected_output.emplace_back(Shape::from_json(json_shape.value())); return test_params; } @@ -271,7 +318,7 @@ struct DeflateTestParams: TestParams void PrintTo(const DeflateTestParams& params, std::ostream* os) { - *os << "Testing " << params.name << " (" << params.description << ")...\n"; + *os << "Testing " << params.name << "...\n"; *os << "hole " << params.shape.to_string(0) << "\n"; *os << "offset " << params.offset << "\n"; *os << "expected_output\n"; @@ -293,36 +340,6 @@ TEST_P(DeflateTest, Deflate) for (const Shape& hole: output) std::cout << "- " << hole.to_string(2) << std::endl; - if (test_params.write_json || test_params.write_svg) { - std::string base_filename = "deflate_" + fs::path(test_params.name).filename().replace_extension("").string(); - - if (test_params.write_json) { - test_params.shape.write_json(base_filename + "_shape.json"); - for (const auto& shape: test_params.expected_output) - shape.write_json(base_filename + "_expected_output.json"); - for (const auto& shape: output) - shape.write_json(base_filename + "_output.json"); - } - if (test_params.write_svg) { - test_params.shape.write_svg(base_filename + "_shape.svg"); - for (const auto& shape: test_params.expected_output) - shape.write_svg(base_filename + "_expected_output.svg"); - for (const auto& shape: output) - shape.write_svg(base_filename + "_output.svg"); - } - - if (test_params.write_json) { - Writer().add_shape(test_params.shape).write_json(base_filename + "_shapes.json"); - Writer().add_shapes(test_params.expected_output).write_json(base_filename + "_expected_output.json"); - Writer().add_shapes(output).write_json(base_filename + "_output.json"); - } - if (test_params.write_svg) { - Writer().add_shape(test_params.shape).write_svg(base_filename + "_shapes.svg"); - Writer().add_shapes(test_params.expected_output).write_svg(base_filename + "_expected_output.svg"); - Writer().add_shapes(output).write_svg(base_filename + "_output.svg"); - } - } - ASSERT_EQ(output.size(), test_params.expected_output.size()); for (const Shape& expected_hole: test_params.expected_output) { EXPECT_NE(std::find( @@ -336,7 +353,10 @@ TEST_P(DeflateTest, Deflate) INSTANTIATE_TEST_SUITE_P( Shape, DeflateTest, - testing::ValuesIn(DeflateTestParams::read_dir((fs::path("data") / "tests" / "offset" / "deflate").string())), + testing::ValuesIn(std::vector{ + DeflateTestParams::read_json( + (fs::path("data") / "tests" / "offset" / "deflate" / "000.json").string()), + }), [](const testing::TestParamInfo& info) { return fs::path(info.param.name).stem().string(); }); diff --git a/test/rasterization_test.cpp b/test/rasterization_test.cpp index 46177c7..813c2b6 100644 --- a/test/rasterization_test.cpp +++ b/test/rasterization_test.cpp @@ -27,17 +27,6 @@ struct RasterizationTestParams LengthDbl cell_height; - template - static RasterizationTestParams from_json( - basic_json& json_item) - { - RasterizationTestParams test_params; - test_params.shape = ShapeWithHoles::from_json(json_item["shape"]); - test_params.cell_width = json_item["cell_width"]; - test_params.cell_height = json_item["cell_height"]; - return test_params; - } - static RasterizationTestParams read_json( const std::string& file_path) { @@ -50,8 +39,11 @@ struct RasterizationTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + RasterizationTestParams test_params; test_params.name = file_path; + test_params.shape = ShapeWithHoles::from_json(json["shape"]); + test_params.cell_width = json["cell_width"]; + test_params.cell_height = json["cell_height"]; return test_params; } }; diff --git a/test/shape_test.cpp b/test/shape_test.cpp index 96cac11..17a5409 100644 --- a/test/shape_test.cpp +++ b/test/shape_test.cpp @@ -702,19 +702,6 @@ struct ShapeContainsTestParams bool expected_output; - template - static ShapeContainsTestParams from_json( - basic_json& json_item) - { - ShapeContainsTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.point = Point::from_json(json_item["point"]); - test_params.strict = json_item["strict"]; - if (json_item.contains("expected_output")) - test_params.expected_output = json_item["expected_output"]; - return test_params; - } - static ShapeContainsTestParams read_json( const std::string& file_path) { @@ -727,7 +714,13 @@ struct ShapeContainsTestParams nlohmann::json json; file >> json; - return from_json(json); + ShapeContainsTestParams test_params; + test_params.shape = Shape::from_json(json["shape"]); + test_params.point = Point::from_json(json["point"]); + test_params.strict = json["strict"]; + if (json.contains("expected_output")) + test_params.expected_output = json["expected_output"]; + return test_params; } }; diff --git a/test/shapes_intersections_test.cpp b/test/shapes_intersections_test.cpp index f6920ab..4766684 100644 --- a/test/shapes_intersections_test.cpp +++ b/test/shapes_intersections_test.cpp @@ -24,15 +24,6 @@ struct IntersectShapeTestParams bool expected_output; - template - static IntersectShapeTestParams from_json(basic_json& json_item) - { - IntersectShapeTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.expected_output = json_item["expected_output"]; - return test_params; - } - static IntersectShapeTestParams read_json( const std::string& file_path) { @@ -45,7 +36,11 @@ struct IntersectShapeTestParams nlohmann::json json; file >> json; - return from_json(json); + IntersectShapeTestParams test_params; + test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.expected_output = json["expected_output"]; + return test_params; } }; @@ -143,17 +138,6 @@ struct IntersectShapeShapeElementTestParams bool expected_output; - template - static IntersectShapeShapeElementTestParams from_json(basic_json& json_item) - { - IntersectShapeShapeElementTestParams test_params; - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.element = ShapeElement::from_json(json_item["element"]); - test_params.strict = json_item["strict"]; - test_params.expected_output = json_item["expected_output"]; - return test_params; - } - static IntersectShapeShapeElementTestParams read_json( const std::string& file_path) { @@ -166,8 +150,12 @@ struct IntersectShapeShapeElementTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + IntersectShapeShapeElementTestParams test_params; test_params.name = file_path; + test_params.shape = Shape::from_json(json["shape"]); + test_params.element = ShapeElement::from_json(json["element"]); + test_params.strict = json["strict"]; + test_params.expected_output = json["expected_output"]; return test_params; } }; @@ -240,24 +228,6 @@ struct ComputeIntersectionsPathShapeTestParams std::vector expected_output; - template - static ComputeIntersectionsPathShapeTestParams from_json( - basic_json& json_item) - { - ComputeIntersectionsPathShapeTestParams test_params; - test_params.path = Shape::from_json(json_item["path"]); - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.only_min_max = json_item["only_min_max"]; - for (auto& json_intersection: json_item["expected_output"]) { - PathShapeIntersectionPoint intersection; - intersection.path_element_pos = json_intersection["path_element_pos"]; - intersection.shape_element_pos = json_intersection["shape_element_pos"]; - intersection.point = Point::from_json(json_intersection["point"]); - test_params.expected_output.emplace_back(intersection); - } - return test_params; - } - static ComputeIntersectionsPathShapeTestParams read_json( const std::string& file_path) { @@ -270,8 +240,18 @@ struct ComputeIntersectionsPathShapeTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + ComputeIntersectionsPathShapeTestParams test_params; test_params.name = file_path; + test_params.path = Shape::from_json(json["path"]); + test_params.shape = Shape::from_json(json["shape"]); + test_params.only_min_max = json["only_min_max"]; + for (auto& json_intersection: json["expected_output"]) { + PathShapeIntersectionPoint intersection; + intersection.path_element_pos = json_intersection["path_element_pos"]; + intersection.shape_element_pos = json_intersection["shape_element_pos"]; + intersection.point = Point::from_json(json_intersection["point"]); + test_params.expected_output.emplace_back(intersection); + } return test_params; } }; @@ -360,24 +340,6 @@ struct ComputeStrictIntersectionsPathShapeTestParams std::vector expected_output; - template - static ComputeStrictIntersectionsPathShapeTestParams from_json( - basic_json& json_item) - { - ComputeStrictIntersectionsPathShapeTestParams test_params; - test_params.path = Shape::from_json(json_item["path"]); - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.only_first = json_item["only_first"]; - for (auto& json_intersection: json_item["expected_output"]) { - PathShapeIntersectionPoint intersection; - intersection.path_element_pos = json_intersection["path_element_pos"]; - intersection.shape_element_pos = json_intersection["shape_element_pos"]; - intersection.point = Point::from_json(json_intersection["point"]); - test_params.expected_output.emplace_back(intersection); - } - return test_params; - } - static ComputeStrictIntersectionsPathShapeTestParams read_json( const std::string& file_path) { @@ -390,7 +352,19 @@ struct ComputeStrictIntersectionsPathShapeTestParams nlohmann::json json; file >> json; - return from_json(json); + ComputeStrictIntersectionsPathShapeTestParams test_params; + test_params.name = file_path; + test_params.path = Shape::from_json(json["path"]); + test_params.shape = Shape::from_json(json["shape"]); + test_params.only_first = json["only_first"]; + for (auto& json_intersection: json["expected_output"]) { + PathShapeIntersectionPoint intersection; + intersection.path_element_pos = json_intersection["path_element_pos"]; + intersection.shape_element_pos = json_intersection["shape_element_pos"]; + intersection.point = Point::from_json(json_intersection["point"]); + test_params.expected_output.emplace_back(intersection); + } + return test_params; } }; @@ -469,18 +443,6 @@ struct IntersectShapeShapeTestParams bool expected_output; - template - static IntersectShapeShapeTestParams from_json( - basic_json& json_item) - { - IntersectShapeShapeTestParams test_params; - test_params.shape_1 = Shape::from_json(json_item["shape_1"]); - test_params.shape_2 = Shape::from_json(json_item["shape_2"]); - test_params.strict = json_item["strict"]; - test_params.expected_output = json_item["expected_output"]; - return test_params; - } - static IntersectShapeShapeTestParams read_json( const std::string& file_path) { @@ -493,8 +455,12 @@ struct IntersectShapeShapeTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + IntersectShapeShapeTestParams test_params; test_params.name = file_path; + test_params.shape_1 = Shape::from_json(json["shape_1"]); + test_params.shape_2 = Shape::from_json(json["shape_2"]); + test_params.strict = json["strict"]; + test_params.expected_output = json["expected_output"]; return test_params; } }; @@ -605,19 +571,6 @@ struct IntersectShapeWithHolesShapeTestParams bool expected_output; - template - static IntersectShapeWithHolesShapeTestParams from_json( - basic_json& json_item) - { - IntersectShapeWithHolesShapeTestParams test_params; - test_params.shape_with_holes = ShapeWithHoles::from_json(json_item["shape_with_holes"]); - test_params.shape = Shape::from_json(json_item["shape"]); - test_params.strict = json_item["strict"]; - if (json_item.contains("expected_output")) - test_params.expected_output = json_item["expected_output"]; - return test_params; - } - static IntersectShapeWithHolesShapeTestParams read_json( const std::string& file_path) { @@ -630,8 +583,13 @@ struct IntersectShapeWithHolesShapeTestParams nlohmann::json json; file >> json; - auto test_params = from_json(json); + IntersectShapeWithHolesShapeTestParams test_params; test_params.name = file_path; + test_params.shape_with_holes = ShapeWithHoles::from_json(json["shape_with_holes"]); + test_params.shape = Shape::from_json(json["shape"]); + test_params.strict = json["strict"]; + if (json.contains("expected_output")) + test_params.expected_output = json["expected_output"]; return test_params; } }; @@ -755,18 +713,6 @@ struct IntersectShapeWithHolesShapeWithHolesTestParams bool expected_output; - template - static IntersectShapeWithHolesShapeWithHolesTestParams from_json( - basic_json& json_item) - { - IntersectShapeWithHolesShapeWithHolesTestParams test_params; - test_params.shape_with_holes_1 = ShapeWithHoles::from_json(json_item["shape_with_holes_1"]); - test_params.shape_with_holes_2 = ShapeWithHoles::from_json(json_item["shape_with_holes_2"]); - test_params.strict = json_item["strict"]; - test_params.expected_output = json_item["expected_output"]; - return test_params; - } - static IntersectShapeWithHolesShapeWithHolesTestParams read_json( const std::string& file_path) { @@ -779,7 +725,13 @@ struct IntersectShapeWithHolesShapeWithHolesTestParams nlohmann::json json; file >> json; - return from_json(json); + IntersectShapeWithHolesShapeWithHolesTestParams test_params; + test_params.name = file_path; + test_params.shape_with_holes_1 = ShapeWithHoles::from_json(json["shape_with_holes_1"]); + test_params.shape_with_holes_2 = ShapeWithHoles::from_json(json["shape_with_holes_2"]); + test_params.strict = json["strict"]; + test_params.expected_output = json["expected_output"]; + return test_params; } }; diff --git a/test/test_params.hpp b/test/test_params.hpp deleted file mode 100644 index c470e54..0000000 --- a/test/test_params.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include "shape/shape.hpp" - -#include - -#include - -namespace fs = boost::filesystem; - -template -struct TestParams -{ - std::string name; - std::string description; - bool write_json = false; - bool write_svg = false; - - - static T from_json( - nlohmann::basic_json<>& json_item) - { - T t; - if (json_item.contains("description")) - t.description = json_item["description"]; - if (json_item.contains("write_json")) - t.write_json = json_item["write_json"]; - if (json_item.contains("write_svg")) - t.write_svg = json_item["write_svg"]; - return t; - } - - static T read_json( - const std::string& file_path) - { - std::ifstream file(file_path); - if (!file.good()) { - throw std::runtime_error( - FUNC_SIGNATURE + ": " - "unable to open file \"" + file_path + "\"."); - } - - nlohmann::json json; - file >> json; - return T::from_json(json); - } - - static std::vector read_dir( - const std::string& dir_path) - { - std::vector params; - if (fs::is_directory(dir_path)) { - std::vector files_in_directory; - std::copy(fs::directory_iterator(dir_path), fs::directory_iterator(), std::back_inserter(files_in_directory)); - std::sort(files_in_directory.begin(), files_in_directory.end()); // Sort paths in alphabetical order - for (const fs::path& entry : files_in_directory) { - if (entry.extension().string() == ".json") { - T test_params = read_json(entry.string()); - test_params.name = entry.string(); - params.emplace_back(test_params); - } - } - } - return params; - } -}; diff --git a/test/trapezoidation_test.cpp b/test/trapezoidation_test.cpp index d399711..69cc807 100644 --- a/test/trapezoidation_test.cpp +++ b/test/trapezoidation_test.cpp @@ -12,17 +12,6 @@ struct TrapezoidationTestParams std::vector expected_output; std::string name; - template - static TrapezoidationTestParams from_json( - basic_json& json_item) - { - TrapezoidationTestParams test_params; - test_params.shape = ShapeWithHoles::from_json(json_item["shape"]); - for (auto& json_trapezoid: json_item["expected_output"].items()) - test_params.expected_output.emplace_back(GeneralizedTrapezoid::from_json(json_trapezoid.value())); - return test_params; - } - static TrapezoidationTestParams read_json( const std::string& file_path) { @@ -35,7 +24,12 @@ struct TrapezoidationTestParams nlohmann::json json; file >> json; - return from_json(json); + TrapezoidationTestParams test_params; + test_params.name = file_path; + test_params.shape = ShapeWithHoles::from_json(json["shape"]); + for (auto& json_trapezoid: json["expected_output"].items()) + test_params.expected_output.emplace_back(GeneralizedTrapezoid::from_json(json_trapezoid.value())); + return test_params; } };