// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. // 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 #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) #ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST template bg::model::linestring

create_linestring() { bg::model::linestring

l1; P p1(1, 2); bg::append(l1, p1); return l1; } template bg::model::multi_linestring create_multi_linestring() { bg::model::multi_linestring ml1; L l1(create_linestring

()); ml1.push_back(l1); ml1.push_back(l1); return ml1; } template void check_multi_linestring(ML& to_check, L l1) { ML cur; cur.push_back(l1); cur.push_back(l1); 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::multi_linestring ml1(create_multi_linestring()); check_multi_linestring(ml1, L(create_linestring

())); } template void test_copy_constructor() { bg::model::multi_linestring ml1 = create_multi_linestring(); check_multi_linestring(ml1, L(create_linestring

())); } template void test_copy_assignment() { bg::model::multi_linestring ml1(create_multi_linestring()), ml2; ml2 = ml1; check_multi_linestring(ml2, L(create_linestring

())); } template void test_concept() { typedef bg::model::multi_linestring ML; BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiLinestring) ); BOOST_CONCEPT_ASSERT( (bg::concepts::MultiLinestring) ); typedef typename bg::coordinate_type::type T; typedef typename bg::point_type::type PML; boost::ignore_unused(); } template void test_all() { typedef bg::model::linestring

L; test_default_constructor(); test_copy_constructor(); test_copy_assignment(); test_concept(); } template void test_custom_multi_linestring(bg::model::linestring

IL) { typedef bg::model::linestring

L; std::initializer_list LIL = {IL}; bg::model::multi_linestring ml1(LIL); std::ostringstream out; out << bg::dsv(ml1); BOOST_CHECK_EQUAL(out.str(), "(((1, 1), (2, 2), (3, 3), (0, 0), (0, 2), (0, 3)))"); } template void test_custom() { #ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST std::initializer_list

IL1 = {P(1, 1), P(2, 2), P(3, 3)}; std::initializer_list

IL2 = {P(0, 0), P(0, 2), P(0, 3)}; bg::model::linestring

l1; bg::append(l1, IL1); bg::append(l1, IL2); test_custom_multi_linestring

(l1); #endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST } 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; }