// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, 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) #ifndef GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP #define GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP #include // Determine debug/release mode // (it would be convenient if Boost.Config or Boost.Test would define this) // Note that they might be combined (e.g. for optimize+no inline) #if defined (BOOST_CLANG) || defined(BOOST_GCC) #if defined(__OPTIMIZE__) #define BOOST_GEOMETRY_COMPILER_MODE_RELEASE #endif #if defined(__NO_INLINE__) #define BOOST_GEOMETRY_COMPILER_MODE_DEBUG #endif #endif #if defined(BOOST_MSVC) #if defined(_DEBUG) #define BOOST_GEOMETRY_COMPILER_MODE_DEBUG #else #define BOOST_GEOMETRY_COMPILER_MODE_RELEASE #endif #endif #if defined(BOOST_MSVC) // We deliberately mix float/double's so turn off warnings #pragma warning( disable : 4244 ) // For (new since Boost 1.40) warning in Boost.Test on putenv/posix #pragma warning( disable : 4996 ) //#pragma warning( disable : 4305 ) #endif // defined(BOOST_MSVC) #include #include #include #include #include // Include some always-included-for-testing files #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST) // Until Boost.Test fixes it, silence warning issued by clang: #ifdef __clang__ # pragma clang diagnostic push // warning: unused variable 'check_is_close' [-Wunused-variable] # pragma clang diagnostic ignored "-Wunused-variable" // warnings when -Wconversion is set # pragma clang diagnostic ignored "-Wsign-conversion" # pragma clang diagnostic ignored "-Wshorten-64-to-32" #endif # include #ifndef BOOST_TEST_MODULE # include //# include # include #endif #ifdef __clang__ # pragma clang diagnostic pop #endif #endif #if defined(HAVE_TTMATH) # include #endif #if defined(HAVE_CLN) || defined(HAVE_GMP) # include #endif #if defined(HAVE_GMP) # include #endif #if defined(HAVE_CLN) # include #endif // For all tests: // - do NOT use "using namespace boost::geometry" to make clear what is Boost.Geometry // - use bg:: as short alias #include #include #include #include #include namespace bg = boost::geometry; template inline T1 if_typed_tt(T1 value_tt, T2 value) { #if defined(HAVE_TTMATH) return boost::is_same::type::value ? value_tt : value; #else boost::ignore_unused(value_tt); return value; #endif } template inline T if_typed(T value_typed, T value) { return boost::is_same::value ? value_typed : value; } template inline std::string type_for_assert_message() { bool const ccw = bg::point_order::value == bg::counterclockwise || bg::point_order::value == bg::counterclockwise; bool const open = bg::closure::value == bg::open || bg::closure::value == bg::open; std::ostringstream out; out << string_from_type::type>::name() << (ccw ? " ccw" : "") << (open ? " open" : ""); return out.str(); } struct geographic_policy { template static inline CoordinateType apply(CoordinateType const& value) { return value; } }; struct mathematical_policy { template static inline CoordinateType apply(CoordinateType const& value) { return 90 - value; } }; typedef double default_test_type; #if defined(BOOST_GEOMETRY_USE_RESCALING) #define BG_IF_RESCALED(a, b) a #else #define BG_IF_RESCALED(a, b) b #endif #if defined(BOOST_GEOMETRY_USE_KRAMER_RULE) #define BG_IF_KRAMER(a, b) a #else #define BG_IF_KRAMER(a, b) b #endif inline void BoostGeometryWriteTestConfiguration() { std::cout << std::endl << "Test configuration:" << std::endl; #if defined(BOOST_GEOMETRY_USE_RESCALING) std::cout << " - Using rescaling" << std::endl; #endif #if defined(BOOST_GEOMETRY_USE_KRAMER_RULE) std::cout << " - Using Kramer rule" << std::endl; #else std::cout << " - Using general form" << std::endl; #endif #if defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) std::cout << " - Testing only one type" << std::endl; #endif #if defined(BOOST_GEOMETRY_TEST_ONLY_ONE_ORDER) std::cout << " - Testing only one order" << std::endl; #endif #if defined(BOOST_GEOMETRY_TEST_FAILURES) std::cout << " - Including failing test cases" << std::endl; #endif std::cout << " - Default test type: " << string_from_type::name() << std::endl; std::cout << std::endl; } #endif // GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP