mirror of
https://github.com/boostorg/core.git
synced 2025-07-29 12:27:42 +02:00
Add sv_ends_with_test
This commit is contained in:
@ -255,6 +255,7 @@ run sv_copy_test.cpp ;
|
||||
run sv_substr_test.cpp ;
|
||||
run sv_compare_test.cpp ;
|
||||
run sv_starts_with_test.cpp ;
|
||||
run sv_ends_with_test.cpp ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
50
test/sv_ends_with_test.cpp
Normal file
50
test/sv_ends_with_test.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv( "" );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "" ) );
|
||||
|
||||
BOOST_TEST( !sv.ends_with( boost::core::string_view( "1" ) ) );
|
||||
BOOST_TEST( !sv.ends_with( '1' ) );
|
||||
BOOST_TEST( !sv.ends_with( "1" ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "123" );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "" ) );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "3" ) ) );
|
||||
BOOST_TEST( sv.ends_with( '3' ) );
|
||||
BOOST_TEST( sv.ends_with( "3" ) );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "23" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "23" ) );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "123" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "123" ) );
|
||||
|
||||
BOOST_TEST( !sv.ends_with( boost::core::string_view( "1234" ) ) );
|
||||
BOOST_TEST( !sv.ends_with( "1234" ) );
|
||||
|
||||
BOOST_TEST( !sv.ends_with( boost::core::string_view( "2" ) ) );
|
||||
BOOST_TEST( !sv.ends_with( '2' ) );
|
||||
BOOST_TEST( !sv.ends_with( "2" ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user