Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.contains / contains.ptr.pass.cpp
blob99f400fa0c37b38e986fced4d45c0858ee101996
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, c++20
10 // <string>
12 // constexpr bool contains(const CharT *x) const;
14 #include <string>
15 #include <cassert>
17 #include "test_macros.h"
19 template <class S>
20 constexpr void test_string() {
21 const char* s = "abcde";
22 S s0;
23 S s1{s + 4, 1};
24 S s3{s + 2, 3};
25 S sNot{"xyz", 3};
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>();
67 return true;
70 int main(int, char**) {
71 test();
72 static_assert(test());
74 return 0;