mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
fix boost unit test framework in cmake and add cmake files
This commit is contained in:
parent
1e54b3475f
commit
aa508bf53a
@ -13,6 +13,7 @@ add_library(boost_geometry INTERFACE)
|
||||
add_library(Boost::geometry ALIAS boost_geometry)
|
||||
|
||||
target_include_directories(boost_geometry INTERFACE include)
|
||||
target_compile_features(boost_geometry INTERFACE cxx_std_14)
|
||||
|
||||
target_link_libraries(boost_geometry
|
||||
INTERFACE
|
||||
@ -65,18 +66,15 @@ if(BOOST_GEOMETRY_BUILD_OPTIONAL)
|
||||
INTERFACE
|
||||
Boost::thread
|
||||
)
|
||||
endif()
|
||||
|
||||
# Requirements for extensions
|
||||
if(BOOST_GEOMETRY_BUILD_OPTIONAL)
|
||||
# Requirements for extensions
|
||||
target_link_libraries(boost_geometry
|
||||
INTERFACE
|
||||
Boost::endian
|
||||
Boost::predef
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_features(boost_geometry INTERFACE cxx_std_14)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
@ -104,12 +102,13 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
any
|
||||
lexical_cast
|
||||
math
|
||||
multiprecision
|
||||
qvm
|
||||
rational
|
||||
serialization
|
||||
tokenizer
|
||||
variant
|
||||
multiprecision)
|
||||
test)
|
||||
|
||||
if (BOOST_SRC_DIR_IS_VALID)
|
||||
set(BOOST_EXCLUDE_LIBRARIES ${PROJECT_NAME})
|
||||
|
@ -14,41 +14,21 @@ function(boost_geometry_add_unit_test prefix item)
|
||||
set(unit_test_name "boost_geometry_${prefix}_${item}")
|
||||
add_executable(${unit_test_name} ${item}.cpp)
|
||||
|
||||
target_link_libraries(${unit_test_name} PRIVATE Boost::geometry)
|
||||
|
||||
# Add a dependendcy to Boost.Geometry
|
||||
target_link_libraries(${unit_test_name}
|
||||
PRIVATE
|
||||
Boost::algorithm
|
||||
Boost::any
|
||||
Boost::array
|
||||
Boost::assert
|
||||
Boost::concept_check
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::function_types
|
||||
Boost::iterator
|
||||
Boost::lexical_cast
|
||||
Boost::math
|
||||
Boost::move
|
||||
Boost::mpl
|
||||
Boost::multiprecision
|
||||
Boost::numeric_conversion
|
||||
Boost::qvm
|
||||
Boost::range
|
||||
Boost::rational
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::tokenizer
|
||||
Boost::tuple
|
||||
Boost::type_traits
|
||||
Boost::utility
|
||||
Boost::variant
|
||||
)
|
||||
Boost::geometry)
|
||||
|
||||
target_include_directories(${unit_test_name} PRIVATE "${PROJECT_SOURCE_DIR}/test" .)
|
||||
|
||||
# Add the Boost.Test framework
|
||||
target_include_directories(${unit_test_name} PRIVATE "${BOOST_SRC_DIR}/libs/test/include" .)
|
||||
# For unit tests, add a dependency to the unit test framework (in header only mode)
|
||||
target_link_libraries(${unit_test_name}
|
||||
PRIVATE
|
||||
Boost::included_unit_test_framework)
|
||||
|
||||
# Include the main Geometry test folder and the current folder
|
||||
target_include_directories(${unit_test_name}
|
||||
PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/test"
|
||||
.)
|
||||
|
||||
# To compile with C++14
|
||||
target_compile_features(${unit_test_name} PRIVATE cxx_std_14)
|
||||
|
@ -6,4 +6,8 @@
|
||||
|
||||
add_subdirectory(area)
|
||||
add_subdirectory(buffer)
|
||||
add_subdirectory(detail)
|
||||
add_subdirectory(overlay)
|
||||
add_subdirectory(relate)
|
||||
add_subdirectory(set_operations)
|
||||
add_subdirectory(within)
|
||||
|
15
test/algorithms/detail/CMakeLists.txt
Normal file
15
test/algorithms/detail/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
foreach(item IN ITEMS
|
||||
calculate_point_order
|
||||
approximately_equals
|
||||
partition
|
||||
tupled_output
|
||||
visit
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/util/condition.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
|
||||
template <typename P>
|
||||
@ -81,18 +83,29 @@ void test_all(E const multiplier, std::size_t expected_index)
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
constexpr bool has_long_double = sizeof(long double) > sizeof(double);
|
||||
|
||||
double m = 1000.0;
|
||||
test_all<bg::model::point<long double, 2, bg::cs::cartesian>>(m, 54);
|
||||
if (BOOST_GEOMETRY_CONDITION(has_long_double))
|
||||
{
|
||||
test_all<bg::model::point<long double, 2, bg::cs::cartesian>>(m, 54);
|
||||
}
|
||||
test_all<bg::model::point<double, 2, bg::cs::cartesian>>(m, 43);
|
||||
test_all<bg::model::point<float, 2, bg::cs::cartesian>>(m, 24);
|
||||
|
||||
m *= 1000.0;
|
||||
test_all<bg::model::point<long double, 2, bg::cs::cartesian>>(m, 44);
|
||||
if (BOOST_GEOMETRY_CONDITION(has_long_double))
|
||||
{
|
||||
test_all<bg::model::point<long double, 2, bg::cs::cartesian>>(m, 44);
|
||||
}
|
||||
test_all<bg::model::point<double, 2, bg::cs::cartesian>>(m, 33);
|
||||
test_all<bg::model::point<float, 2, bg::cs::cartesian>>(m, 24);
|
||||
|
||||
m *= 1000.0;
|
||||
test_all<bg::model::point<long double, 2, bg::cs::cartesian>>(m, 34);
|
||||
if (BOOST_GEOMETRY_CONDITION(has_long_double))
|
||||
{
|
||||
test_all<bg::model::point<long double, 2, bg::cs::cartesian>>(m, 34);
|
||||
}
|
||||
test_all<bg::model::point<double, 2, bg::cs::cartesian>>(m, 23);
|
||||
test_all<bg::model::point<float, 2, bg::cs::cartesian>>(m, 23);
|
||||
|
||||
|
38
test/algorithms/overlay/CMakeLists.txt
Normal file
38
test/algorithms/overlay/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
# Cartesian
|
||||
foreach(item IN ITEMS
|
||||
assemble
|
||||
copy_segment_point
|
||||
get_clusters
|
||||
get_distance_measure
|
||||
get_ring
|
||||
get_turn_info
|
||||
get_turns
|
||||
get_turns_const
|
||||
get_turns_areal_areal
|
||||
get_turns_linear_areal
|
||||
get_turns_linear_linear
|
||||
overlay
|
||||
sort_by_side_basic
|
||||
sort_by_side
|
||||
relative_order
|
||||
select_rings
|
||||
self_intersection_points
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
||||
|
||||
# Spherical
|
||||
foreach(item IN ITEMS
|
||||
get_turns_areal_areal_sph
|
||||
get_turns_linear_areal_sph
|
||||
get_turns_linear_linear_sph
|
||||
get_turns_linear_linear_geo
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/util/condition.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
|
||||
#include <vector>
|
||||
@ -93,6 +95,7 @@ void test_get_clusters_border_cases(typename bg::coordinate_type<Point>::type ep
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
constexpr bool has_long_double = sizeof(long double) > sizeof(double);
|
||||
using fp = bg::model::point<float, 2, bg::cs::cartesian>;
|
||||
using dp = bg::model::point<double, 2, bg::cs::cartesian>;
|
||||
using ep = bg::model::point<long double, 2, bg::cs::cartesian>;
|
||||
@ -101,11 +104,15 @@ int test_main(int, char* [])
|
||||
test_get_clusters<dp>();
|
||||
test_get_clusters<ep>();
|
||||
|
||||
// These constant relate to the threshold in get_clusters.hpp,
|
||||
// These constant relate to the (earlier) thresholds in get_clusters.hpp,
|
||||
// and the used floating point type.
|
||||
// (thresholds are now replaced by common_approximately_equals_epsilon_multiplier)
|
||||
test_get_clusters_border_cases<fp>(1.0e-5);
|
||||
test_get_clusters_border_cases<dp>(1.0e-14);
|
||||
test_get_clusters_border_cases<ep>(1.0e-17);
|
||||
if (BOOST_GEOMETRY_CONDITION(has_long_double))
|
||||
{
|
||||
test_get_clusters_border_cases<ep>(1.0e-17);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
25
test/algorithms/relate/CMakeLists.txt
Normal file
25
test/algorithms/relate/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
# Cartesian
|
||||
foreach(item IN ITEMS
|
||||
relate_const_custom
|
||||
relate_areal_areal
|
||||
relate_linear_areal
|
||||
relate_linear_linear
|
||||
relate_pointlike_geometry
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
||||
|
||||
# Spherical
|
||||
foreach(item IN ITEMS
|
||||
relate_areal_areal_sph
|
||||
relate_linear_areal_sph
|
||||
relate_linear_linear_sph
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
26
test/algorithms/within/CMakeLists.txt
Normal file
26
test/algorithms/within/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
# Boost.Geometry
|
||||
# Copyright (c) 2024 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)
|
||||
|
||||
# Cartesian
|
||||
foreach(item IN ITEMS
|
||||
within
|
||||
within_areal_areal
|
||||
within_gc
|
||||
within_linear_areal
|
||||
within_linear_linear
|
||||
within_multi
|
||||
within_pointlike_geometry
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
||||
|
||||
# Spherical
|
||||
foreach(item IN ITEMS
|
||||
within_sph
|
||||
within_sph_geo
|
||||
)
|
||||
boost_geometry_add_unit_test("algorithms" ${item})
|
||||
endforeach()
|
Loading…
x
Reference in New Issue
Block a user