diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 593b527..3696e80 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -405,6 +405,9 @@ compile sv_construct_test_cx2.cpp ; run sv_hash_test.cpp : : : $(CPP11) /boost/container_hash//boost_container_hash ; +run sv_format_test.cpp + : : : $(pedantic-errors) ; + run span_test.cpp ; run span_types_test.cpp ; run span_constructible_test.cpp ; diff --git a/test/sv_format_test.cpp b/test/sv_format_test.cpp new file mode 100644 index 0000000..dc2c045 --- /dev/null +++ b/test/sv_format_test.cpp @@ -0,0 +1,30 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include + +#if !( defined(__cpp_lib_format) && __cpp_lib_format >= 201907L ) + +BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_lib_format is not defined to at least 201907L" ) +int main() {} + +#else + +#include +#include + +int main() +{ + BOOST_TEST_EQ( std::format( "{}", boost::core::string_view( "123" ) ), std::format( "{}", std::string_view( "123" ) ) ); + BOOST_TEST_EQ( std::format( "{:s}", boost::core::string_view( "123" ) ), std::format( "{:s}", std::string_view( "123" ) ) ); + BOOST_TEST_EQ( std::format( "{:^7}", boost::core::string_view( "123" ) ), std::format( "{:^7}", std::string_view( "123" ) ) ); + BOOST_TEST_EQ( std::format( "{:-^7}", boost::core::string_view( "123" ) ), std::format( "{:-^7}", std::string_view( "123" ) ) ); + + return boost::report_errors(); +} + +#endif