1800259c9SMarshall Clow //===----------------------------------------------------------------------===//
2800259c9SMarshall Clow //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6800259c9SMarshall Clow //
7800259c9SMarshall Clow //===----------------------------------------------------------------------===//
8*02d11757SLouis Dionne 
931cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11, c++14, c++17
10800259c9SMarshall Clow 
11800259c9SMarshall Clow // <string_view>
12800259c9SMarshall Clow 
13800259c9SMarshall Clow //   constexpr bool ends_with(charT x) const noexcept;
14800259c9SMarshall Clow 
15800259c9SMarshall Clow #include <string_view>
16800259c9SMarshall Clow #include <cassert>
17800259c9SMarshall Clow 
18800259c9SMarshall Clow #include "test_macros.h"
19cc89063bSNico Weber #include "constexpr_char_traits.h"
20800259c9SMarshall Clow 
main(int,char **)212df59c50SJF Bastien int main(int, char**)
22800259c9SMarshall Clow {
23800259c9SMarshall Clow     {
24800259c9SMarshall Clow     typedef std::string_view SV;
25800259c9SMarshall Clow     SV  sv1 {};
26800259c9SMarshall Clow     SV  sv2 { "abcde", 5 };
27800259c9SMarshall Clow 
28800259c9SMarshall Clow     ASSERT_NOEXCEPT(sv1.ends_with('e'));
29800259c9SMarshall Clow 
30800259c9SMarshall Clow     assert (!sv1.ends_with('e'));
31800259c9SMarshall Clow     assert (!sv1.ends_with('x'));
32800259c9SMarshall Clow     assert ( sv2.ends_with('e'));
33800259c9SMarshall Clow     assert (!sv2.ends_with('x'));
34800259c9SMarshall Clow     }
35800259c9SMarshall Clow 
36800259c9SMarshall Clow #if TEST_STD_VER > 11
37800259c9SMarshall Clow     {
38800259c9SMarshall Clow     typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
39800259c9SMarshall Clow     constexpr SV  sv1 {};
40800259c9SMarshall Clow     constexpr SV  sv2 { "abcde", 5 };
41800259c9SMarshall Clow     static_assert (!sv1.ends_with('e'), "" );
42800259c9SMarshall Clow     static_assert (!sv1.ends_with('x'), "" );
43800259c9SMarshall Clow     static_assert ( sv2.ends_with('e'), "" );
44800259c9SMarshall Clow     static_assert (!sv2.ends_with('x'), "" );
45800259c9SMarshall Clow     }
46800259c9SMarshall Clow #endif
472df59c50SJF Bastien 
482df59c50SJF Bastien   return 0;
49800259c9SMarshall Clow }
50