// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands. // 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 template void test_one(std::string const& case_id, std::string const& wkt, bool expected) { Geometry geometry; bg::read_wkt(wkt, geometry); bg::correct(geometry); bool detected = bg::is_convex(geometry); BOOST_CHECK_MESSAGE(detected == expected, "Not as expected, case: " << case_id << " / expected: " << expected << " / detected: " << detected); } template void test_all() { // rectangular, with concavity std::string const concave1 = "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))"; std::string const triangle = "polygon((1 1, 1 4, 5 1, 1 1))"; test_one >("triangle", triangle, true); test_one >("concave1", concave1, false); test_one >("triangle", triangle, true); test_one >("concave1", concave1, false); test_one >("box", "box(0 0,2 2)", true); } int test_main(int, char* []) { test_all >(); test_all >(); return 0; }