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 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 
11 // <string_view>
12 
13 //   constexpr bool contains(charT x) const noexcept;
14 
15 #include <string_view>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 
test()20 constexpr bool test()
21 {
22     using SV = std::string_view;
23 
24     SV sv1 {};
25     SV sv2 {"abcde", 5};
26 
27     ASSERT_NOEXCEPT(sv1.contains('e'));
28 
29     assert(!sv1.contains('c'));
30     assert(!sv1.contains('e'));
31     assert(!sv1.contains('x'));
32     assert( sv2.contains('c'));
33     assert( sv2.contains('e'));
34     assert(!sv2.contains('x'));
35 
36     return true;
37 }
38 
main(int,char **)39 int main(int, char**)
40 {
41     test();
42     static_assert(test());
43 
44     return 0;
45 }
46