mirror of
https://github.com/boostorg/lexical_cast.git
synced 2026-01-19 04:22:08 +00:00
Run all the tests in CMake, add CMake runs into CI. Drop dependency on Boost.TypeTraits (#90)
This commit is contained in:
36
.github/workflows/ci.yml
vendored
36
.github/workflows/ci.yml
vendored
@@ -17,6 +17,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-24.04
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
@@ -66,9 +69,20 @@ jobs:
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
./b2 -j4 variant=debug tools/inspect
|
||||
|
||||
- name: Run CMake tests
|
||||
if: ${{matrix.toolset == 'gcc-14'}}
|
||||
run: |
|
||||
cd ../boost-root/
|
||||
mkdir __build
|
||||
cd __build
|
||||
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=lexical_cast -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 ..
|
||||
cmake --build . --target tests
|
||||
ctest --output-on-failure --no-tests=error
|
||||
cd ..
|
||||
rm -rf __build
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
@@ -108,8 +122,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc
|
||||
cxxstd: "14,17,latest"
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: msvc
|
||||
@@ -146,7 +160,21 @@ jobs:
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run CMake tests
|
||||
if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||
shell: cmd
|
||||
run: |
|
||||
choco install --no-progress ninja
|
||||
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64
|
||||
cd ../boost-root/
|
||||
mkdir __build
|
||||
cd __build
|
||||
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=lexical_cast ..
|
||||
cmake --build . --target tests --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
cd ..
|
||||
rm -rf __build
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
|
||||
@@ -18,12 +18,9 @@ target_link_libraries(boost_lexical_cast
|
||||
Boost::container
|
||||
Boost::core
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ constant boost_dependencies :
|
||||
/boost/config//boost_config
|
||||
/boost/container//boost_container
|
||||
/boost/core//boost_core
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/type_traits//boost_type_traits ;
|
||||
/boost/throw_exception//boost_throw_exception ;
|
||||
|
||||
project /boost/lexical_cast
|
||||
: common-requirements
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/detail/lcast_precision.hpp>
|
||||
|
||||
#include <boost/lexical_cast/detail/widest_char.hpp>
|
||||
@@ -66,19 +65,19 @@ namespace boost {
|
||||
template < class Char >
|
||||
struct normalize_single_byte_char
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct normalize_single_byte_char< signed char >
|
||||
{
|
||||
typedef char type;
|
||||
using type = char;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct normalize_single_byte_char< unsigned char >
|
||||
{
|
||||
typedef char type;
|
||||
using type = char;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -118,7 +117,7 @@ namespace boost {
|
||||
template < typename Char >
|
||||
struct stream_char_common< boost::conversion::detail::buffer_view< Char > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template < typename Char >
|
||||
@@ -138,13 +137,13 @@ namespace boost {
|
||||
template < class Char, class Traits, class Alloc >
|
||||
struct stream_char_common< std::basic_string< Char, Traits, Alloc > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template < class Char, class Traits, class Alloc >
|
||||
struct stream_char_common< boost::container::basic_string< Char, Traits, Alloc > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template < typename Char, std::size_t N >
|
||||
@@ -181,25 +180,31 @@ namespace boost {
|
||||
template < class Char, class Traits >
|
||||
struct stream_char_common< std::basic_string_view< Char, Traits > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
#endif
|
||||
template < class Char, class Traits >
|
||||
struct stream_char_common< boost::basic_string_view< Char, Traits > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
#ifdef BOOST_HAS_INT128
|
||||
template <> struct stream_char_common< boost::int128_type >: public boost::type_identity< char > {};
|
||||
template <> struct stream_char_common< boost::uint128_type >: public boost::type_identity< char > {};
|
||||
template <> struct stream_char_common< boost::int128_type >
|
||||
{
|
||||
using type = char;
|
||||
};
|
||||
template <> struct stream_char_common< boost::uint128_type >
|
||||
{
|
||||
using type = char;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
template <>
|
||||
struct stream_char_common< wchar_t >
|
||||
{
|
||||
typedef char type;
|
||||
using type = char;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <type_traits>
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
|
||||
namespace boost { namespace detail {
|
||||
@@ -122,7 +121,7 @@ struct lexical_cast_dynamic_num_ignoring_minus
|
||||
static inline bool try_convert(Source arg, Target& result) noexcept {
|
||||
typedef typename std::conditional<
|
||||
std::is_floating_point<Source>::value,
|
||||
boost::type_identity<Source>,
|
||||
std::conditional<true, Source, Source>, // std::type_identity emulation
|
||||
boost::detail::lcast::make_unsigned<Source>
|
||||
>::type usource_lazy_t;
|
||||
typedef typename usource_lazy_t::type usource_t;
|
||||
|
||||
65
test/CMakeLists.txt
Normal file
65
test/CMakeLists.txt
Normal file
@@ -0,0 +1,65 @@
|
||||
# Copyright (c) 2016-2025 Antony Polukhin
|
||||
# Distributed under 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(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(NOT HAVE_BOOST_TEST)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::lexical_cast Boost::core)
|
||||
|
||||
boost_test(TYPE run SOURCES lexical_cast_test.cpp LINK_LIBRARIES Boost::type_traits)
|
||||
boost_test(TYPE run SOURCES loopback_test.cpp)
|
||||
boost_test(TYPE run SOURCES abstract_test.cpp)
|
||||
boost_test(TYPE run SOURCES noncopyable_test.cpp)
|
||||
boost_test(TYPE run SOURCES vc8_bug_test.cpp)
|
||||
boost_test(TYPE run SOURCES implicit_convert.cpp)
|
||||
boost_test(TYPE run SOURCES wchars_test.cpp)
|
||||
boost_test(TYPE run SOURCES float_types_test.cpp)
|
||||
|
||||
if(NOT MSVC)
|
||||
# Make sure that LexicalCast works the same way as some of the C++ Standard Libraries
|
||||
boost_test(TYPE run SOURCES float_types_test.cpp COMPILE_DEFINITIONS BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD NAME float_types_non_opt)
|
||||
endif()
|
||||
|
||||
boost_test(TYPE run SOURCES inf_nan_test.cpp)
|
||||
boost_test(TYPE run SOURCES containers_test.cpp)
|
||||
boost_test(TYPE run SOURCES empty_input_test.cpp LINK_LIBRARIES Boost::range)
|
||||
boost_test(TYPE run SOURCES pointers_test.cpp)
|
||||
|
||||
if(MSVC)
|
||||
boost_test(TYPE compile SOURCES typedefed_wchar_test.cpp COMPILE_OPTIONS "/Zc:wchar_t-")
|
||||
boost_test(TYPE run SOURCES typedefed_wchar_test_runtime.cpp COMPILE_OPTIONS "/Zc:wchar_t-")
|
||||
endif()
|
||||
|
||||
boost_test(TYPE run SOURCES no_locale_test.cpp
|
||||
COMPILE_DEFINITIONS BOOST_NO_STD_LOCALE BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
|
||||
LINK_LIBRARIES Boost::range
|
||||
)
|
||||
|
||||
boost_test(TYPE run SOURCES no_exceptions_test.cpp
|
||||
COMPILE_OPTIONS "-fno-exceptions"
|
||||
COMPILE_DEFINITIONS
|
||||
_HAS_EXCEPTIONS=0 # MSVC stdlib
|
||||
_STLP_NO_EXCEPTIONS # STLPort
|
||||
LINK_LIBRARIES Boost::range
|
||||
)
|
||||
|
||||
boost_test(TYPE run SOURCES iterator_range_test.cpp LINK_LIBRARIES Boost::range)
|
||||
boost_test(TYPE run SOURCES string_view_test.cpp LINK_LIBRARIES Boost::utility)
|
||||
boost_test(TYPE run SOURCES arrays_test.cpp LINK_LIBRARIES Boost::array)
|
||||
boost_test(TYPE run SOURCES integral_types_test.cpp LINK_LIBRARIES Boost::type_traits)
|
||||
boost_test(TYPE run SOURCES stream_detection_test.cpp)
|
||||
boost_test(TYPE run SOURCES stream_traits_test.cpp LINK_LIBRARIES Boost::array Boost::range Boost::utility)
|
||||
|
||||
boost_test(TYPE compile-fail SOURCES to_pointer_test.cpp)
|
||||
boost_test(TYPE compile-fail SOURCES from_volatile.cpp)
|
||||
boost_test(TYPE run SOURCES filesystem_test.cpp LINK_LIBRARIES Boost::filesystem)
|
||||
boost_test(TYPE run SOURCES try_lexical_convert.cpp)
|
||||
|
||||
file(GLOB EXAMPLE_FILES "../example/*.cpp")
|
||||
foreach (testsourcefile ${EXAMPLE_FILES})
|
||||
boost_test(TYPE run SOURCES ${testsourcefile} LINK_LIBRARIES Boost::variant Boost::date_time)
|
||||
endforeach()
|
||||
Reference in New Issue
Block a user