[mlir][PDLL] Allow (and ignore) `-D` tablegen macros. (#124166)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.contains / contains.string_view.pass.cpp
blob619a718794b14e1d8f12b72ce15570b8dedddece
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(basic_string_view x) const noexcept;
14 #include <string>
15 #include <cassert>
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> >;
24 const char* s = "abcde";
25 S s0;
26 S s1{s + 1, 1};
27 S s3{s + 1, 3};
28 S s5{s, 5};
29 S sNot{"xyz", 3};
31 SV sv0;
32 SV sv1{s + 1, 1};
33 SV sv2{s + 1, 2};
34 SV sv3{s + 1, 3};
35 SV sv4{s + 1, 4};
36 SV sv5{s, 5};
37 SV svNot{"xyz", 3};
38 SV svNot2{"bd", 2};
39 SV svNot3{"dcb", 3};
41 ASSERT_NOEXCEPT(s0.contains(sv0));
43 assert(s0.contains(sv0));
44 assert(!s0.contains(sv1));
46 assert(s1.contains(sv0));
47 assert(s1.contains(sv1));
48 assert(!s1.contains(sv2));
49 assert(!s1.contains(sv3));
50 assert(!s1.contains(sv4));
51 assert(!s1.contains(sv5));
52 assert(!s1.contains(svNot));
53 assert(!s1.contains(svNot2));
54 assert(!s1.contains(svNot3));
56 assert(s3.contains(sv0));
57 assert(s3.contains(sv1));
58 assert(s3.contains(sv2));
59 assert(s3.contains(sv3));
60 assert(!s3.contains(sv4));
61 assert(!s3.contains(sv5));
62 assert(!s3.contains(svNot));
63 assert(!s3.contains(svNot2));
64 assert(!s3.contains(svNot3));
66 assert(s5.contains(sv0));
67 assert(s5.contains(sv1));
68 assert(s5.contains(sv2));
69 assert(s5.contains(sv3));
70 assert(s5.contains(sv4));
71 assert(s5.contains(sv5));
72 assert(!s5.contains(svNot));
73 assert(!s5.contains(svNot2));
74 assert(!s5.contains(svNot3));
76 assert(sNot.contains(sv0));
77 assert(!sNot.contains(sv1));
78 assert(!sNot.contains(sv2));
79 assert(!sNot.contains(sv3));
80 assert(!sNot.contains(sv4));
81 assert(!sNot.contains(sv5));
82 assert(sNot.contains(svNot));
83 assert(!sNot.contains(svNot2));
84 assert(!sNot.contains(svNot3));
87 constexpr bool test() {
88 test_string<char, std::allocator>();
90 return true;
93 int main(int, char**) {
94 test();
95 static_assert(test());
97 return 0;