Add sv_format_test.cpp. Refs #190.

This commit is contained in:
Peter Dimov
2025-06-25 16:51:59 +03:00
parent 58f469cd80
commit 16d8f5f8ff
2 changed files with 33 additions and 0 deletions

View File

@ -405,6 +405,9 @@ compile sv_construct_test_cx2.cpp ;
run sv_hash_test.cpp : : : $(CPP11) <library>/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 ;

30
test/sv_format_test.cpp Normal file
View File

@ -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 <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#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 <format>
#include <string_view>
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