mirror of
https://github.com/boostorg/lexical_cast.git
synced 2026-07-21 13:23:34 +00:00
fix ci: turn on import std tests, fix libc++ build (#96)
This PR: - enables tests with `import std` usage in CI - add all tests to build with cmake_subdir_test (because there was only a subset of tests supported) - fixes tests build with `libc++` - disables some tests with wchar_t with 'libc++'
This commit is contained in:
+35
-26
@@ -20,6 +20,7 @@ jobs:
|
||||
- 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
|
||||
compiler: g++-14
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
@@ -40,6 +41,7 @@ jobs:
|
||||
- toolset: clang-19
|
||||
cxxstd: "20,23"
|
||||
os: ubuntu-24.04
|
||||
compiler: clang++-19
|
||||
install: clang-19 llvm-19 libclang-rt-19-dev libc++-19-dev libc++abi-19-dev clang-tools-19
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -74,43 +76,50 @@ jobs:
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -j4 variant=debug tools/inspect
|
||||
- name: Run modules tests wihtout 'import std;'
|
||||
|
||||
|
||||
- name: Run modules tests without 'import std;'
|
||||
if: ${{matrix.toolset == 'clang-19'}}
|
||||
run: |
|
||||
cd ../boost-root/libs/lexical_cast
|
||||
mkdir build_module
|
||||
cd build_module
|
||||
cmake -DBOOST_USE_MODULES=1 -GNinja -DCMAKE_CXX_COMPILER=clang++-19 ../test/cmake_subdir_test/
|
||||
cmake --build .
|
||||
ctest -V
|
||||
cd ..
|
||||
cmake -S test/cmake_subdir_test -B build_module \
|
||||
-GNinja \
|
||||
-DBUILD_TESTING=1 \
|
||||
-DBOOST_USE_MODULES=1 \
|
||||
-DCMAKE_CXX_COMPILER=clang++-19 \
|
||||
-DCMAKE_C_COMPILER=clang-19
|
||||
cmake --build build_module
|
||||
ctest --test-dir build_module -V --no-tests=error
|
||||
rm -rf build_module
|
||||
|
||||
- name: Run modules tests
|
||||
if: false
|
||||
# if: ${{matrix.toolset == 'clang-19'}}
|
||||
if: ${{matrix.toolset == 'clang-19'}}
|
||||
run: |
|
||||
cd ../boost-root/libs/lexical_cast
|
||||
mkdir build_module
|
||||
cd build_module
|
||||
cmake -DBUILD_TESTING=1 -DBOOST_USE_MODULES=1 -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja ../test/cmake_subdir_test/
|
||||
cmake --build .
|
||||
ctest -V
|
||||
cd ..
|
||||
cmake -S test/cmake_subdir_test -B build_module \
|
||||
-GNinja \
|
||||
-DBUILD_TESTING=1 \
|
||||
-DBOOST_USE_MODULES=1 \
|
||||
-DCMAKE_CXX_COMPILER=clang++-19 \
|
||||
-DCMAKE_C_COMPILER=clang-19 \
|
||||
-DCMAKE_CXX_FLAGS=-stdlib=libc++ \
|
||||
-DCMAKE_CXX_STANDARD=23 \
|
||||
-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 \
|
||||
-DCMAKE_CXX_MODULE_STD=ON
|
||||
cmake --build build_module
|
||||
ctest --test-dir build_module -V --no-tests=error
|
||||
rm -rf build_module
|
||||
|
||||
- name: Run CMake tests
|
||||
if: ${{matrix.toolset == 'gcc-14'}}
|
||||
if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}}
|
||||
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 ..
|
||||
cmake -S . -B __build \
|
||||
-DBUILD_TESTING=1 \
|
||||
-DBOOST_INCLUDE_LIBRARIES=lexical_cast \
|
||||
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
|
||||
-DCMAKE_C_COMPILER=${{matrix.toolset}}
|
||||
cmake --build __build --target tests
|
||||
ctest --test-dir __build --output-on-failure --no-tests=error
|
||||
rm -rf __build
|
||||
|
||||
- name: Run tests
|
||||
@@ -187,7 +196,7 @@ jobs:
|
||||
git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
git submodule update --init tools/boostdep libs/test
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
|
||||
@@ -200,7 +209,7 @@ jobs:
|
||||
cd ../boost-root/
|
||||
mkdir __build
|
||||
cd __build
|
||||
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=lexical_cast ..
|
||||
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=lexical_cast -G Ninja ..
|
||||
cmake --build . --target tests --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
@@ -219,7 +228,7 @@ jobs:
|
||||
cmake --build .
|
||||
ctest --no-tests=error -V
|
||||
|
||||
- name: Run modules tests wihtout 'import std;'
|
||||
- name: Run modules tests without 'import std;'
|
||||
if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||
shell: cmd
|
||||
run: |
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ if (BOOST_USE_MODULES)
|
||||
target_compile_definitions(boost_lexical_cast PRIVATE BOOST_LEXICAL_CAST_USE_STD_MODULE)
|
||||
message(STATUS "Using `import std;`")
|
||||
else()
|
||||
message(STATUS "`import std;` is not awailable")
|
||||
message(STATUS "`import std;` is not available")
|
||||
endif()
|
||||
set(__scope PUBLIC)
|
||||
else()
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
//[lexical_cast_args_example
|
||||
//`The following example treats command line arguments as a sequence of numeric data
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
int main(int /*argc*/, char * argv[])
|
||||
{
|
||||
using boost::lexical_cast;
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
Step 1: Making a functor that converts any type to a string and remembers result:
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/fusion/include/for_each.hpp>
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
struct stringize_functor {
|
||||
@@ -38,7 +44,6 @@ public:
|
||||
};
|
||||
|
||||
//` Step 2: Applying `stringize_functor` to each element in sequence:
|
||||
#include <boost/fusion/include/for_each.hpp>
|
||||
template <class Sequence>
|
||||
std::string stringize(const Sequence& seq) {
|
||||
std::string result;
|
||||
@@ -47,9 +52,6 @@ std::string stringize(const Sequence& seq) {
|
||||
}
|
||||
|
||||
//` Step 3: Using the `stringize` with different types:
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
|
||||
int main() {
|
||||
std::tuple<char, int, char, int> decim('-', 10, 'e', 5);
|
||||
if (stringize(decim) != "-10e5") {
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4996) // `strerror` is not safe
|
||||
#endif
|
||||
|
||||
@@ -10,9 +10,13 @@
|
||||
In this example we'll make a `to_long_double` method that converts value of the Boost.Variant to `long double`.
|
||||
*/
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#ifdef BOOST_USE_MODULES
|
||||
#include <compare>
|
||||
#endif
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
struct to_long_double_functor: boost::static_visitor<long double> {
|
||||
template <class T>
|
||||
long double operator()(const T& v) const {
|
||||
|
||||
+56
-38
@@ -3,64 +3,82 @@
|
||||
# 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()
|
||||
if(NOT TARGET tests)
|
||||
add_custom_target(tests)
|
||||
endif()
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::lexical_cast Boost::core)
|
||||
function(boost_lexical_cast_add_test_impl test_name test_file libs)
|
||||
add_executable(${test_name} ${test_file})
|
||||
target_link_libraries(${test_name} PRIVATE ${libs})
|
||||
add_test(NAME ${test_name} COMMAND ${test_name})
|
||||
add_dependencies(tests ${test_name})
|
||||
endfunction()
|
||||
|
||||
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)
|
||||
function(boost_lexical_cast_add_test name libs)
|
||||
set(test_name lexical_cast_${name})
|
||||
set(test_file ${name}.cpp)
|
||||
boost_lexical_cast_add_test_impl(${test_name} ${test_file} "Boost::lexical_cast;${libs}")
|
||||
endfunction()
|
||||
|
||||
boost_lexical_cast_add_test(lexical_cast_test Boost::type_traits)
|
||||
boost_lexical_cast_add_test(loopback_test "")
|
||||
boost_lexical_cast_add_test(abstract_test "")
|
||||
boost_lexical_cast_add_test(noncopyable_test "")
|
||||
boost_lexical_cast_add_test(vc8_bug_test "")
|
||||
boost_lexical_cast_add_test(implicit_convert "")
|
||||
boost_lexical_cast_add_test(wchars_test "")
|
||||
boost_lexical_cast_add_test(float_types_test "")
|
||||
|
||||
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)
|
||||
boost_lexical_cast_add_test_impl(lexical_cast_float_types_non_opt float_types_test.cpp Boost::lexical_cast)
|
||||
target_compile_definitions(lexical_cast_float_types_non_opt PRIVATE BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD)
|
||||
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)
|
||||
boost_lexical_cast_add_test(inf_nan_test "")
|
||||
boost_lexical_cast_add_test(containers_test "")
|
||||
boost_lexical_cast_add_test(empty_input_test Boost::range)
|
||||
boost_lexical_cast_add_test(pointers_test "")
|
||||
|
||||
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-")
|
||||
add_executable(lexical_cast_typedefed_wchar_test_compile typedefed_wchar_test.cpp)
|
||||
target_compile_options(lexical_cast_typedefed_wchar_test_compile PRIVATE "/Zc:wchar_t-")
|
||||
|
||||
boost_lexical_cast_add_test(typedefed_wchar_test_runtime "")
|
||||
target_compile_options(lexical_cast_typedefed_wchar_test_runtime PRIVATE "/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_lexical_cast_add_test(no_locale_test Boost::range)
|
||||
target_compile_definitions(lexical_cast_no_locale_test
|
||||
PRIVATE
|
||||
BOOST_NO_STD_LOCALE
|
||||
BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
|
||||
)
|
||||
|
||||
boost_test(TYPE run SOURCES no_exceptions_test.cpp
|
||||
COMPILE_OPTIONS "-fno-exceptions"
|
||||
COMPILE_DEFINITIONS
|
||||
boost_lexical_cast_add_test_impl(lexical_cast_no_exceptions_test no_exceptions_test.cpp "Boost::container;Boost::range")
|
||||
target_include_directories(lexical_cast_no_exceptions_test PRIVATE ../include)
|
||||
target_compile_definitions(lexical_cast_no_exceptions_test
|
||||
PRIVATE
|
||||
_HAS_EXCEPTIONS=0 # MSVC stdlib
|
||||
_STLP_NO_EXCEPTIONS # STLPort
|
||||
LINK_LIBRARIES Boost::range
|
||||
)
|
||||
if(MSVC)
|
||||
target_compile_definitions(lexical_cast_no_exceptions_test PRIVATE BOOST_NO_EXCEPTIONS)
|
||||
endif()
|
||||
target_compile_options(lexical_cast_no_exceptions_test PRIVATE "-fno-exceptions")
|
||||
|
||||
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_lexical_cast_add_test(iterator_range_test Boost::range)
|
||||
boost_lexical_cast_add_test(string_view_test Boost::utility)
|
||||
boost_lexical_cast_add_test(arrays_test Boost::array)
|
||||
boost_lexical_cast_add_test(integral_types_test Boost::type_traits)
|
||||
boost_lexical_cast_add_test(stream_detection_test "")
|
||||
boost_lexical_cast_add_test(stream_traits_test "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)
|
||||
boost_lexical_cast_add_test(filesystem_test Boost::filesystem)
|
||||
boost_lexical_cast_add_test(try_lexical_convert "")
|
||||
|
||||
file(GLOB EXAMPLE_FILES "../example/*.cpp")
|
||||
foreach (testsourcefile ${EXAMPLE_FILES})
|
||||
boost_test(TYPE run SOURCES ${testsourcefile} LINK_LIBRARIES Boost::variant Boost::date_time)
|
||||
get_filename_component(testname ${testsourcefile} NAME_WE)
|
||||
boost_lexical_cast_add_test_impl(lexical_cast_example_${testname} ${testsourcefile} "Boost::variant;Boost::date_time")
|
||||
endforeach()
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
// Test abstract class. Bug 1358600:
|
||||
// http://sf.net/tracker/?func=detail&aid=1358600&group_id=7586&atid=107586
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
class A
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS) && !defined(_LIBCPP_VERSION) && !defined(BOOST_MSVC)
|
||||
@@ -61,7 +61,7 @@ static void testing_template_array_output_on_spec_value(T val)
|
||||
BOOST_TEST_THROWS(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING) && !defined(_LIBCPP_VERSION)
|
||||
typedef ArrayT<wchar_t, 300> warr_type;
|
||||
typedef ArrayT<wchar_t, 3> wshort_arr_type;
|
||||
std::wstring wethalon(L"100");
|
||||
@@ -156,7 +156,7 @@ static void testing_template_array_output_on_char_value()
|
||||
BOOST_TEST_THROWS(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING) && !defined(_LIBCPP_VERSION)
|
||||
typedef ArrayT<wchar_t, 4> warr_type;
|
||||
typedef ArrayT<wchar_t, 3> wshort_arr_type;
|
||||
std::wstring wethalon(L"100");
|
||||
@@ -238,11 +238,13 @@ static void testing_template_array_output_on_char_value()
|
||||
|
||||
void testing_boost_array_output_conversion()
|
||||
{
|
||||
#ifndef _LIBCPP_VERSION
|
||||
testing_template_array_output_on_char_value<boost::array>();
|
||||
testing_template_array_output_on_spec_value<boost::array>(100);
|
||||
testing_template_array_output_on_spec_value<boost::array>(static_cast<short>(100));
|
||||
testing_template_array_output_on_spec_value<boost::array>(static_cast<unsigned short>(100));
|
||||
testing_template_array_output_on_spec_value<boost::array>(static_cast<unsigned int>(100));
|
||||
#endif
|
||||
}
|
||||
|
||||
void testing_std_array_output_conversion()
|
||||
@@ -344,7 +346,10 @@ static void testing_generic_array_input_conversion()
|
||||
|
||||
void testing_boost_array_input_conversion()
|
||||
{
|
||||
#ifndef _LIBCPP_VERSION
|
||||
testing_generic_array_input_conversion<boost::array>();
|
||||
#endif
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void testing_std_array_input_conversion()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright (c) 2016-2025 Antony Polukhin
|
||||
# Copyright (c) 2025-2026 Fedor Osetrov
|
||||
# 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
|
||||
|
||||
@@ -6,20 +7,70 @@ cmake_minimum_required(VERSION 3.5...4.0)
|
||||
|
||||
project(lexical_cast_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../../../assert boostorg/assert)
|
||||
add_subdirectory(../../../core boostorg/core)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
add_subdirectory(../../../container boostorg/container)
|
||||
add_subdirectory(../../../container_hash boostorg/container_hash)
|
||||
add_subdirectory(../../../detail boostorg/detail)
|
||||
add_subdirectory(../../../intrusive boostorg/intrusive)
|
||||
add_subdirectory(../../../move boostorg/move)
|
||||
add_subdirectory(../../../throw_exception boostorg/throw_exception)
|
||||
add_subdirectory(../../../type_traits boostorg/type_traits)
|
||||
set(deps
|
||||
|
||||
add_subdirectory(../../ boostorg/lexical_cast)
|
||||
# Library dependencies
|
||||
config
|
||||
container
|
||||
core
|
||||
throw_exception
|
||||
|
||||
# Test dependencies
|
||||
algorithm
|
||||
array
|
||||
align
|
||||
assert
|
||||
atomic
|
||||
bind
|
||||
compat
|
||||
concept_check
|
||||
container_hash
|
||||
conversion
|
||||
date_time
|
||||
describe
|
||||
detail
|
||||
exception
|
||||
filesystem
|
||||
function
|
||||
function_types
|
||||
functional
|
||||
fusion
|
||||
integer
|
||||
intrusive
|
||||
io
|
||||
iterator
|
||||
move
|
||||
mp11
|
||||
mpl
|
||||
numeric/conversion
|
||||
optional
|
||||
predef
|
||||
preprocessor
|
||||
range
|
||||
regex
|
||||
scope
|
||||
smart_ptr
|
||||
static_assert
|
||||
system
|
||||
test
|
||||
tokenizer
|
||||
tuple
|
||||
type_index
|
||||
type_traits
|
||||
typeof
|
||||
unordered
|
||||
utility
|
||||
variant
|
||||
variant2
|
||||
winapi
|
||||
)
|
||||
|
||||
foreach(dep IN LISTS deps)
|
||||
add_subdirectory(../../../${dep} boostorg/${dep})
|
||||
endforeach()
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(../../ boostorg/lexical_cast)
|
||||
|
||||
if (BOOST_USE_MODULES)
|
||||
add_executable(boost_lexical_cast_module_usage ../modules/usage_sample.cpp)
|
||||
@@ -27,26 +78,3 @@ if (BOOST_USE_MODULES)
|
||||
add_test(NAME boost_lexical_cast_module_usage COMMAND boost_lexical_cast_module_usage)
|
||||
endif()
|
||||
|
||||
list(APPEND RUN_TESTS_SOURCES
|
||||
lexical_cast_test.cpp
|
||||
loopback_test.cpp
|
||||
abstract_test.cpp
|
||||
noncopyable_test.cpp
|
||||
vc8_bug_test.cpp
|
||||
implicit_convert.cpp
|
||||
float_types_test.cpp
|
||||
inf_nan_test.cpp
|
||||
containers_test.cpp
|
||||
pointers_test.cpp
|
||||
integral_types_test.cpp
|
||||
stream_detection_test.cpp
|
||||
try_lexical_convert.cpp
|
||||
)
|
||||
|
||||
foreach (testsourcefile ${RUN_TESTS_SOURCES})
|
||||
get_filename_component(testname ${testsourcefile} NAME_WLE)
|
||||
add_executable(${PROJECT_NAME}_${testname} ../${testsourcefile})
|
||||
target_link_libraries(${PROJECT_NAME}_${testname} Boost::lexical_cast Boost::type_traits Boost::core)
|
||||
add_test(NAME ${PROJECT_NAME}_${testname} COMMAND ${PROJECT_NAME}_${testname})
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/container/string.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
void testing_boost_containers_basic_string()
|
||||
|
||||
@@ -8,15 +8,16 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include "escape_struct.hpp"
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "escape_struct.hpp"
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
//
|
||||
// Test lexical_cast usage with long filesystem::path. Bug 7704.
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
void test_filesystem()
|
||||
{
|
||||
boost::filesystem::path p;
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
// 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_LEXICAL_CAST_DETAIL_TEST_ON_OLD
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#else
|
||||
// Make sure that tests work the same way on non-optimized version
|
||||
#include "lexical_cast_old.hpp"
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#else
|
||||
// Make sure that tests work the same way on non-optimized version
|
||||
#include "lexical_cast_old.hpp"
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_TEST_CLOSE_FRACTION
|
||||
// Naiive, but works for most tests in this file
|
||||
@@ -304,7 +306,7 @@ void test_float_typess_for_overflows()
|
||||
BOOST_TEST_THROWS(lexical_cast<test_t>("1"+s_max_value), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<test_t>("9"+s_max_value), bad_lexical_cast);
|
||||
#endif
|
||||
|
||||
#if !(defined(_LIBCPP_VERSION) && defined(BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD))
|
||||
if ( std::is_same<test_t,float>::value )
|
||||
{
|
||||
BOOST_TEST_THROWS(lexical_cast<test_t>( (std::numeric_limits<double>::max)() ), bad_lexical_cast);
|
||||
@@ -340,6 +342,7 @@ void test_float_typess_for_overflows()
|
||||
<= (std::numeric_limits<long double>::min)() / 2 + std::numeric_limits<test_t>::epsilon()
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef CHECK_CLOSE_ABS_DIFF
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
struct oops {
|
||||
operator int () const {
|
||||
return 41;
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/cmath.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
//
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
@@ -34,6 +32,8 @@
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \
|
||||
&& !(defined(BOOST_MSVC) && BOOST_MSVC < 1300)
|
||||
#define LCAST_TEST_LONGLONG
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
@@ -136,7 +136,7 @@ void test_it_range_using_char(CharT* one, CharT* eleven)
|
||||
#endif
|
||||
BOOST_TEST_EQ(lexical_cast<class_with_user_defined_sream_operators>(crng2), 1);
|
||||
|
||||
#ifndef BOOST_LCAST_NO_WCHAR_T
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(_LIBCPP_VERSION)
|
||||
BOOST_TEST(lexical_cast<std::wstring>(rng1) == L"1");
|
||||
BOOST_TEST(lexical_cast<std::wstring>(crng1) == L"1");
|
||||
BOOST_TEST(lexical_cast<std::wstring>(rng2) == L"1");
|
||||
@@ -191,7 +191,7 @@ void test_signed_char_iterator_ranges()
|
||||
|
||||
void test_wchar_iterator_ranges()
|
||||
{
|
||||
#ifndef BOOST_LCAST_NO_WCHAR_T
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(_LIBCPP_VERSION)
|
||||
typedef wchar_t test_char_type;
|
||||
test_char_type data1[] = L"1";
|
||||
test_char_type data2[] = L"11";
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast/detail/lcast_precision.hpp>
|
||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||
#include <boost/lexical_cast/detail/widest_char.hpp>
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
//
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
@@ -31,6 +29,8 @@
|
||||
#include <algorithm> // std::transform
|
||||
#include <memory>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \
|
||||
&& !(defined(BOOST_MSVC) && BOOST_MSVC < 1300)
|
||||
#define LCAST_TEST_LONGLONG
|
||||
@@ -528,8 +528,10 @@ void test_char16_conversions()
|
||||
// There's no std::ctype<char16_t> in Xcode_15.0.1
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS) && !defined(__APPLE__)
|
||||
BOOST_TEST(u"100" == lexical_cast<std::u16string>(u"100"));
|
||||
#if !defined(_LIBCPP_VERSION) // libc++ also does not have std::ctype<char16_t>
|
||||
BOOST_TEST(u"1" == lexical_cast<std::u16string>(u'1'));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_char32_conversions()
|
||||
@@ -537,8 +539,10 @@ void test_char32_conversions()
|
||||
// There's no std::ctype<char32_t> in Xcode_15.0.1
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS) && !defined(__APPLE__)
|
||||
BOOST_TEST(U"100" == lexical_cast<std::u32string>(U"100"));
|
||||
#if !defined(_LIBCPP_VERSION) // libc++ also does not have std::ctype<char32_t>
|
||||
BOOST_TEST(U"1" == lexical_cast<std::u32string>(U'1'));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_getting_pointer_to_function()
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
// Test round-tripping conversion FPT -> string -> FPT,
|
||||
// where FPT is Floating Point Type.
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if (defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__NetBSD__) \
|
||||
|| (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
|
||||
|| defined(__MINGW64__)
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
|
||||
#endif
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "escape_struct.hpp"
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
@@ -17,6 +15,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
// Testing compilation and some basic usage with BOOST_NO_STD_LOCALE
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
//
|
||||
// Test that Source can be non-copyable.
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
class Noncopyable : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM)
|
||||
typedef std::strstream ss_t;
|
||||
#else
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
||||
///////////////////////// char streamable classes ///////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast/detail/converter_lexical.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
|
||||
@@ -19,6 +17,8 @@
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
||||
template <class StringView>
|
||||
void test_string_view_conversion() {
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/lexical_cast/try_lexical_convert.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast/try_lexical_convert.hpp>
|
||||
|
||||
using namespace boost::conversion;
|
||||
|
||||
void try_uncommon_cases()
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// implementation has changed and it does not use stringstream for casts
|
||||
// to integral types
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
@@ -20,6 +19,8 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
@@ -8,9 +8,14 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
|
||||
Reference in New Issue
Block a user