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, c++20
12 // constexpr bool contains(const CharT *x) const;
17 #include "test_macros.h"
20 constexpr void test_string() {
21 const char* s
= "abcde";
27 assert(s0
.contains(""));
28 assert(!s0
.contains("e"));
30 assert(s1
.contains(""));
31 assert(!s1
.contains("d"));
32 assert(s1
.contains("e"));
33 assert(!s1
.contains("de"));
34 assert(!s1
.contains("cd"));
35 assert(!s1
.contains("cde"));
36 assert(!s1
.contains("bcde"));
37 assert(!s1
.contains("abcde"));
38 assert(!s1
.contains("xyz"));
40 assert(s3
.contains(""));
41 assert(s3
.contains("d"));
42 assert(s3
.contains("e"));
43 assert(s3
.contains("de"));
44 assert(s3
.contains("cd"));
45 assert(!s3
.contains("ce"));
46 assert(s3
.contains("cde"));
47 assert(!s3
.contains("edc"));
48 assert(!s3
.contains("bcde"));
49 assert(!s3
.contains("abcde"));
50 assert(!s3
.contains("xyz"));
52 assert(sNot
.contains(""));
53 assert(!sNot
.contains("d"));
54 assert(!sNot
.contains("e"));
55 assert(!sNot
.contains("de"));
56 assert(!sNot
.contains("cd"));
57 assert(!sNot
.contains("cde"));
58 assert(!sNot
.contains("bcde"));
59 assert(!sNot
.contains("abcde"));
60 assert(sNot
.contains("xyz"));
61 assert(!sNot
.contains("zyx"));
64 constexpr bool test() {
65 test_string
<std::string
>();
70 int main(int, char**) {
72 static_assert(test());