// 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 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; bg::assign_values(p1, 1, 2, 3); bg::append(l1, p1); return l1; } template void check_linestring(L& to_check, T x, T y, T z) { BOOST_CHECK_EQUAL(bg::get<0>(to_check[0]), x); BOOST_CHECK_EQUAL(bg::get<1>(to_check[0]), y); BOOST_CHECK_EQUAL(bg::get<2>(to_check[0]), z); } template void test_default_constructor() { bg::model::linestring

l1(create_linestring

()); check_linestring(l1, 1, 2, 3); } template void test_copy_constructor() { bg::model::linestring

l1 = create_linestring

(); check_linestring(l1, 1, 2, 3); } template void test_copy_assignment() { bg::model::linestring

l1(create_linestring

()), l2; l2 = l1; check_linestring(l2, 1, 2, 3); } template void test_concept() { typedef bg::model::linestring

L; BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring) ); BOOST_CONCEPT_ASSERT( (bg::concepts::Linestring) ); typedef typename bg::coordinate_type::type T; typedef typename bg::point_type::type LP; boost::ignore_unused(); } template void test_all() { test_default_constructor

(); test_copy_constructor

(); test_copy_assignment

(); test_concept

(); } template void test_custom_linestring(std::initializer_list

IL) { bg::model::linestring

l1(IL); std::ostringstream out; out << bg::dsv(l1); BOOST_CHECK_EQUAL(out.str(), "((1, 2), (2, 3), (3, 4))"); } template void test_custom() { #ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST std::initializer_list

IL = {P(1, 2), P(2, 3), P(3, 4)}; test_custom_linestring

(IL); #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; }