// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. // 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) #ifndef BOOST_GEOMETRY_TEST_AREA_HPP #define BOOST_GEOMETRY_TEST_AREA_HPP #include #include #include #include #include template void test_area(Geometry const& geometry, typename bg::default_area_result::type expected_area) { typename bg::default_area_result::type area = bg::area(geometry); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::ostringstream out; out << typeid(typename bg::coordinate_type::type).name() << " " << typeid(typename bg::default_area_result::type).name() << " " << "area : " << bg::area(geometry) << std::endl; std::cout << out.str(); #endif BOOST_CHECK_CLOSE(area, expected_area, 0.0001); // Test with explicitly defined strategies bg::strategy::area::cartesian<> strategy1; area = bg::area(geometry, strategy1); bg::strategy::area::cartesian < typename bg::coordinate_type::type > strategy2; area = bg::area(geometry, strategy2); } template void test_geometry(std::string const& wkt, typename bg::default_area_result::type expected_area) { Geometry geometry; bg::read_wkt(wkt, geometry); test_area(geometry, expected_area); } template void test_empty_input(Geometry const& geometry) { try { bg::area(geometry); } catch(bg::empty_input_exception const& ) { return; } BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); } #endif