[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / strings / string.view / string.view.template / ends_with.ptr.pass.cpp
blob51339641632ea5415179b902dfa03d456208a6f2
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
10 // <string_view>
12 // constexpr bool ends_with(const CharT *x) const;
14 #include <string_view>
15 #include <cassert>
17 #include "test_macros.h"
18 #include "constexpr_char_traits.h"
20 int main(int, char**)
23 typedef std::string_view SV;
24 const char *s = "abcde";
25 SV sv0 {};
26 SV sv1 { s + 4, 1 };
27 SV sv2 { s + 3, 2 };
28 // SV sv3 { s + 2, 3 };
29 // SV sv4 { s + 1, 4 };
30 // SV sv5 { s , 5 };
31 SV svNot {"def", 3 };
33 LIBCPP_ASSERT_NOEXCEPT(sv0.ends_with(""));
35 assert ( sv0.ends_with(""));
36 assert (!sv0.ends_with("e"));
38 assert ( sv1.ends_with(""));
39 assert ( sv1.ends_with("e"));
40 assert (!sv1.ends_with("de"));
41 assert (!sv1.ends_with("cde"));
42 assert (!sv1.ends_with("bcde"));
43 assert (!sv1.ends_with("abcde"));
44 assert (!sv1.ends_with("def"));
46 assert ( sv2.ends_with(""));
47 assert ( sv2.ends_with("e"));
48 assert ( sv2.ends_with("de"));
49 assert (!sv2.ends_with("cde"));
50 assert (!sv2.ends_with("bcde"));
51 assert (!sv2.ends_with("abcde"));
52 assert (!sv2.ends_with("def"));
54 assert ( svNot.ends_with(""));
55 assert (!svNot.ends_with("e"));
56 assert (!svNot.ends_with("de"));
57 assert (!svNot.ends_with("cde"));
58 assert (!svNot.ends_with("bcde"));
59 assert (!svNot.ends_with("abcde"));
60 assert ( svNot.ends_with("def"));
63 #if TEST_STD_VER > 11
65 typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
66 constexpr const char *s = "abcde";
67 constexpr SV sv0 {};
68 constexpr SV sv1 { s + 4, 1 };
69 constexpr SV sv2 { s + 3, 2 };
70 // constexpr SV sv3 { s + 2, 3 };
71 // constexpr SV sv4 { s + 1, 4 };
72 // constexpr SV sv5 { s, 5 };
73 constexpr SV svNot {"def", 3 };
75 static_assert ( sv0.ends_with(""), "" );
76 static_assert (!sv0.ends_with("e"), "" );
78 static_assert ( sv1.ends_with(""), "" );
79 static_assert ( sv1.ends_with("e"), "" );
80 static_assert (!sv1.ends_with("de"), "" );
81 static_assert (!sv1.ends_with("cde"), "" );
82 static_assert (!sv1.ends_with("bcde"), "" );
83 static_assert (!sv1.ends_with("abcde"), "" );
84 static_assert (!sv1.ends_with("def"), "" );
86 static_assert ( sv2.ends_with(""), "" );
87 static_assert ( sv2.ends_with("e"), "" );
88 static_assert ( sv2.ends_with("de"), "" );
89 static_assert (!sv2.ends_with("cde"), "" );
90 static_assert (!sv2.ends_with("bcde"), "" );
91 static_assert (!sv2.ends_with("abcde"), "" );
92 static_assert (!sv2.ends_with("def"), "" );
94 static_assert ( svNot.ends_with(""), "" );
95 static_assert (!svNot.ends_with("e"), "" );
96 static_assert (!svNot.ends_with("de"), "" );
97 static_assert (!svNot.ends_with("cde"), "" );
98 static_assert (!svNot.ends_with("bcde"), "" );
99 static_assert (!svNot.ends_with("abcde"), "" );
100 static_assert ( svNot.ends_with("def"), "" );
102 #endif
104 return 0;