// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. // This file was modified by Oracle on 2021. // Modifications copyright (c) 2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include #include #include #include #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) template bg::model::polygon

create_polygon() { bg::model::polygon

pl1; P p1; P p2; P p3; bg::assign_values(p1, 1, 2); bg::assign_values(p2, 2, 0); bg::assign_values(p3, 0, 0); bg::append(pl1, p1); bg::append(pl1, p2); bg::append(pl1, p3); bg::append(pl1, p1); return pl1; } template void check_polygon(PL& to_check, P p1, P p2, P p3) { PL cur; bg::append(cur, p1); bg::append(cur, p2); bg::append(cur, p3); bg::append(cur, p1); std::ostringstream out1, out2; out1 << bg::dsv(to_check); out2 << bg::dsv(cur); BOOST_CHECK_EQUAL(out1.str(), out2.str()); } template void test_default_constructor() { bg::model::polygon

pl1(create_polygon

()); check_polygon(pl1, P(1, 2), P(2, 0), P(0, 0)); } template void test_copy_constructor() { bg::model::polygon

pl1 = create_polygon

(); check_polygon(pl1, P(1, 2), P(2, 0), P(0, 0)); } template void test_copy_assignment() { bg::model::polygon

pl1(create_polygon

()), pl2; pl2 = pl1; check_polygon(pl2, P(1, 2), P(2, 0), P(0, 0)); } template void test_concept() { typedef bg::model::polygon

PL; BOOST_CONCEPT_ASSERT( (bg::concepts::ConstPolygon) ); BOOST_CONCEPT_ASSERT( (bg::concepts::Polygon) ); typedef typename bg::coordinate_type::type T; typedef typename bg::point_type::type PPL; boost::ignore_unused(); } template void test_all() { test_default_constructor

(); test_copy_constructor

(); test_copy_assignment

(); test_concept

(); } template void test_custom_polygon(bg::model::ring

IL) { std::initializer_list > RIL = {IL}; bg::model::polygon

pl1(RIL); std::ostringstream out; out << bg::dsv(pl1); BOOST_CHECK_EQUAL(out.str(), "(((3, 3), (3, 0), (0, 0), (0, 3), (3, 3)))"); } template void test_custom() { std::initializer_list

IL = {P(3, 3), P(3, 0), P(0, 0), P(0, 3), P(3, 3)}; bg::model::ring

r1(IL); test_custom_polygon

(r1); } template void test_cs() { test_all >(); test_all >(); test_all >(); test_custom >(); } int test_main(int, char* []) { test_cs(); test_cs >(); test_cs >(); test_cs >(); test_custom >(); return 0; }