[lld/COFF] Demangle symbol name in discarded section relocation error message (#119726)
[llvm-project.git] / libcxx / test / std / strings / string.view / string.view.template / starts_with.ptr.pass.cpp
blob94582ad93efce55eb48b1ac54420e2a94b4930d3
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // <string_view>
13 // constexpr bool starts_with(string_view x) const noexcept;
15 #include <string_view>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "constexpr_char_traits.h"
21 int main(int, char**) {
23 typedef std::string_view SV;
24 const char* s = "abcde";
25 SV sv0{};
26 SV sv1{s, 1};
27 SV sv2{s, 2};
28 SV svNot{"def", 3};
30 LIBCPP_ASSERT_NOEXCEPT(sv0.starts_with(""));
32 assert(sv0.starts_with(""));
33 assert(!sv0.starts_with("a"));
35 assert(sv1.starts_with(""));
36 assert(sv1.starts_with("a"));
37 assert(!sv1.starts_with("ab"));
38 assert(!sv1.starts_with("abc"));
39 assert(!sv1.starts_with("abcd"));
40 assert(!sv1.starts_with("abcde"));
41 assert(!sv1.starts_with("def"));
43 assert(sv2.starts_with(s + 5));
44 assert(sv2.starts_with("a"));
45 assert(sv2.starts_with("ab"));
46 assert(!sv2.starts_with("abc"));
47 assert(!sv2.starts_with("abcd"));
48 assert(!sv2.starts_with("abcde"));
49 assert(!sv2.starts_with("def"));
51 assert(svNot.starts_with(""));
52 assert(!svNot.starts_with("a"));
53 assert(!svNot.starts_with("ab"));
54 assert(!svNot.starts_with("abc"));
55 assert(!svNot.starts_with("abcd"));
56 assert(!svNot.starts_with("abcde"));
57 assert(svNot.starts_with("def"));
60 #if TEST_STD_VER > 11
62 typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
63 constexpr const char* s = "abcde";
64 constexpr SV sv0{};
65 constexpr SV sv1{s, 1};
66 constexpr SV sv2{s, 2};
67 constexpr SV svNot{"def", 3};
69 static_assert(sv0.starts_with(""), "");
70 static_assert(!sv0.starts_with("a"), "");
72 static_assert(sv1.starts_with(""), "");
73 static_assert(sv1.starts_with("a"), "");
74 static_assert(!sv1.starts_with("ab"), "");
75 static_assert(!sv1.starts_with("abc"), "");
76 static_assert(!sv1.starts_with("abcd"), "");
77 static_assert(!sv1.starts_with("abcde"), "");
78 static_assert(!sv1.starts_with("def"), "");
80 static_assert(sv2.starts_with(s + 5), "");
81 static_assert(sv2.starts_with("a"), "");
82 static_assert(sv2.starts_with("ab"), "");
83 static_assert(!sv2.starts_with("abc"), "");
84 static_assert(!sv2.starts_with("abcd"), "");
85 static_assert(!sv2.starts_with("abcde"), "");
86 static_assert(!sv2.starts_with("def"), "");
88 static_assert(svNot.starts_with(""), "");
89 static_assert(!svNot.starts_with("a"), "");
90 static_assert(!svNot.starts_with("ab"), "");
91 static_assert(!svNot.starts_with("abc"), "");
92 static_assert(!svNot.starts_with("abcd"), "");
93 static_assert(!svNot.starts_with("abcde"), "");
94 static_assert(svNot.starts_with("def"), "");
96 #endif
98 return 0;