1// Copyright 2021 Peter Dimov
2// Distributed under the Boost Software License, Version 1.0.
3// https://www.boost.org/LICENSE_1_0.txt
4
5#include <boost/core/detail/string_view.hpp>
6#include <boost/core/lightweight_test.hpp>
7#include <stdexcept>
8#include <cstddef>
9
10int main()
11{
12 {
13 boost::core::string_view sv( "" );
14
15 BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
16 BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
17 BOOST_TEST( sv.ends_with( "" ) );
18
19 BOOST_TEST( !sv.ends_with( boost::core::string_view( "1" ) ) );
20 BOOST_TEST( !sv.ends_with( '1' ) );
21 BOOST_TEST( !sv.ends_with( "1" ) );
22 }
23
24 {
25 boost::core::string_view sv( "123" );
26
27 BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
28 BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
29 BOOST_TEST( sv.ends_with( "" ) );
30
31 BOOST_TEST( sv.ends_with( boost::core::string_view( "3" ) ) );
32 BOOST_TEST( sv.ends_with( '3' ) );
33 BOOST_TEST( sv.ends_with( "3" ) );
34
35 BOOST_TEST( sv.ends_with( boost::core::string_view( "23" ) ) );
36 BOOST_TEST( sv.ends_with( "23" ) );
37
38 BOOST_TEST( sv.ends_with( boost::core::string_view( "123" ) ) );
39 BOOST_TEST( sv.ends_with( "123" ) );
40
41 BOOST_TEST( !sv.ends_with( boost::core::string_view( "1234" ) ) );
42 BOOST_TEST( !sv.ends_with( "1234" ) );
43
44 BOOST_TEST( !sv.ends_with( boost::core::string_view( "2" ) ) );
45 BOOST_TEST( !sv.ends_with( '2' ) );
46 BOOST_TEST( !sv.ends_with( "2" ) );
47 }
48
49 return boost::report_errors();
50}
51

source code of boost/libs/core/test/sv_ends_with_test.cpp