1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9 
10 // <string_view>
11 
12 //   constexpr bool starts_with(charT x) const noexcept;
13 
14 #include <string_view>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 #include "constexpr_char_traits.h"
19 
main(int,char **)20 int main(int, char**)
21 {
22     {
23     typedef std::string_view SV;
24     SV  sv1 {};
25     SV  sv2 { "abcde", 5 };
26 
27     ASSERT_NOEXCEPT(sv1.starts_with('e'));
28 
29     assert (!sv1.starts_with('a'));
30     assert (!sv1.starts_with('x'));
31     assert ( sv2.starts_with('a'));
32     assert (!sv2.starts_with('x'));
33     }
34 
35 #if TEST_STD_VER > 11
36     {
37     typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
38     constexpr SV  sv1 {};
39     constexpr SV  sv2 { "abcde", 5 };
40     static_assert (!sv1.starts_with('a'), "" );
41     static_assert (!sv1.starts_with('x'), "" );
42     static_assert ( sv2.starts_with('a'), "" );
43     static_assert (!sv2.starts_with('x'), "" );
44     }
45 #endif
46 
47   return 0;
48 }
49