Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.ends_with / ends_with.ptr.pass.cpp
blob23331967d1c730a204bb68723208a3117481f49a
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>
12 // constexpr bool ends_with(const CharT *x) const;
14 #include <string>
15 #include <cassert>
17 #include "test_macros.h"
19 template <class S>
20 constexpr void test_string() {
21 const char* s = "abcde";
23 S s0;
24 S s1{s + 4, 1};
25 S s2{s + 3, 2};
26 // S s3 { s + 2, 3 };
27 // S s4 { s + 1, 4 };
28 // S s5 { s, 5 };
29 S sNot{"def", 3};
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>();
64 return true;
67 int main(int, char**) {
68 test();
69 static_assert(test());
71 return 0;