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
12 // constexpr bool ends_with(const CharT *x) const;
17 #include "test_macros.h"
20 constexpr void test_string() {
21 const char* s
= "abcde";
31 LIBCPP_ASSERT_NOEXCEPT(s0
.ends_with(""));
33 assert(s0
.ends_with(""));
34 assert(!s0
.ends_with("e"));
36 assert(s1
.ends_with(""));
37 assert(s1
.ends_with("e"));
38 assert(!s1
.ends_with("de"));
39 assert(!s1
.ends_with("cde"));
40 assert(!s1
.ends_with("bcde"));
41 assert(!s1
.ends_with("abcde"));
42 assert(!s1
.ends_with("def"));
44 assert(s2
.ends_with(""));
45 assert(s2
.ends_with("e"));
46 assert(s2
.ends_with("de"));
47 assert(!s2
.ends_with("cde"));
48 assert(!s2
.ends_with("bcde"));
49 assert(!s2
.ends_with("abcde"));
50 assert(!s2
.ends_with("def"));
52 assert(sNot
.ends_with(""));
53 assert(!sNot
.ends_with("e"));
54 assert(!sNot
.ends_with("de"));
55 assert(!sNot
.ends_with("cde"));
56 assert(!sNot
.ends_with("bcde"));
57 assert(!sNot
.ends_with("abcde"));
58 assert(sNot
.ends_with("def"));
61 constexpr bool test() {
62 test_string
<std::string
>();
67 int main(int, char**) {
69 static_assert(test());