1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
12 // constexpr bool starts_with(string_view x) const noexcept;
17 #include "test_macros.h"
19 template <class CharT
, template <class> class Alloc
>
20 constexpr void test_string() {
21 using S
= std::basic_string
<CharT
, std::char_traits
<CharT
>, Alloc
<CharT
> >;
22 using SV
= std::basic_string_view
<CharT
, std::char_traits
<CharT
> >;
23 const char* s
= "abcde";
41 ASSERT_NOEXCEPT(s0
.starts_with(sv0
));
43 assert(s0
.starts_with(sv0
));
44 assert(!s0
.starts_with(sv1
));
46 assert(s1
.starts_with(sv0
));
47 assert(s1
.starts_with(sv1
));
48 assert(!s1
.starts_with(sv2
));
49 assert(!s1
.starts_with(sv3
));
50 assert(!s1
.starts_with(sv4
));
51 assert(!s1
.starts_with(sv5
));
52 assert(!s1
.starts_with(svNot
));
54 assert(s2
.starts_with(sv0
));
55 assert(s2
.starts_with(sv1
));
56 assert(s2
.starts_with(sv2
));
57 assert(!s2
.starts_with(sv3
));
58 assert(!s2
.starts_with(sv4
));
59 assert(!s2
.starts_with(sv5
));
60 assert(!s2
.starts_with(svNot
));
62 assert(sNot
.starts_with(sv0
));
63 assert(!sNot
.starts_with(sv1
));
64 assert(!sNot
.starts_with(sv2
));
65 assert(!sNot
.starts_with(sv3
));
66 assert(!sNot
.starts_with(sv4
));
67 assert(!sNot
.starts_with(sv5
));
68 assert(sNot
.starts_with(svNot
));
71 constexpr bool test() {
72 test_string
<char, std::allocator
>();
77 int main(int, char**) {
79 static_assert(test());