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(basic_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
> >;
24 const char* s
= "abcde";
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
>();
93 int main(int, char**) {
95 static_assert(test());