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(const CharT *x) const;
17 #include "test_macros.h"
20 constexpr void test_string() {
21 const char* s
= "abcde";
30 LIBCPP_ASSERT_NOEXCEPT(s0
.starts_with(""));
32 assert(s0
.starts_with(""));
33 assert(!s0
.starts_with("a"));
35 assert(s1
.starts_with(""));
36 assert(s1
.starts_with("a"));
37 assert(!s1
.starts_with("ab"));
38 assert(!s1
.starts_with("abc"));
39 assert(!s1
.starts_with("abcd"));
40 assert(!s1
.starts_with("abcde"));
41 assert(!s1
.starts_with("def"));
43 assert(s2
.starts_with(""));
44 assert(s2
.starts_with("a"));
45 assert(s2
.starts_with("ab"));
46 assert(!s2
.starts_with("abc"));
47 assert(!s2
.starts_with("abcd"));
48 assert(!s2
.starts_with("abcde"));
49 assert(!s2
.starts_with("def"));
51 assert(sNot
.starts_with(""));
52 assert(!sNot
.starts_with("a"));
53 assert(!sNot
.starts_with("ab"));
54 assert(!sNot
.starts_with("abc"));
55 assert(!sNot
.starts_with("abcd"));
56 assert(!sNot
.starts_with("abcde"));
57 assert(sNot
.starts_with("def"));
60 constexpr bool test() {
61 test_string
<std::string
>();
66 int main(int, char**) {
68 static_assert(test());