mirror of
https://github.com/boostorg/core.git
synced 2025-07-29 20:37:22 +02:00
Add sv_format_test.cpp. Refs #190.
This commit is contained in:
@ -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
30
test/sv_format_test.cpp
Normal 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
|
Reference in New Issue
Block a user