Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.starts_with / starts_with.ptr.pass.cpp
blob3647489a0f15f3e6792131f8dcb1fc53909b9554
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 starts_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";
22 S s0{};
23 S s1{s, 1};
24 S s2{s, 2};
25 // S s3 { s, 3 };
26 // S s4 { s, 4 };
27 // S s5 { s, 5 };
28 S sNot{"def", 3};
30 LIBCPP_ASSERT_NOEXCEPT(s0.starts_with(""));
32 assert(s0.starts_with(""));
33 assert(!s0.starts_with("a"));
35 assert(s1.starts_with(""));
36 assert(s1.starts_with("a"));
37 assert(!s1.starts_with("ab"));
38 assert(!s1.starts_with("abc"));
39 assert(!s1.starts_with("abcd"));
40 assert(!s1.starts_with("abcde"));
41 assert(!s1.starts_with("def"));
43 assert(s2.starts_with(""));
44 assert(s2.starts_with("a"));
45 assert(s2.starts_with("ab"));
46 assert(!s2.starts_with("abc"));
47 assert(!s2.starts_with("abcd"));
48 assert(!s2.starts_with("abcde"));
49 assert(!s2.starts_with("def"));
51 assert(sNot.starts_with(""));
52 assert(!sNot.starts_with("a"));
53 assert(!sNot.starts_with("ab"));
54 assert(!sNot.starts_with("abc"));
55 assert(!sNot.starts_with("abcd"));
56 assert(!sNot.starts_with("abcde"));
57 assert(sNot.starts_with("def"));
60 constexpr bool test() {
61 test_string<std::string>();
63 return true;
66 int main(int, char**) {
67 test();
68 static_assert(test());
70 return 0;