Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.nonmembers / string_op!= / string_string_view.pass.cpp
blob1595ec501f4e90cf610e87e284a7a5959bc60002
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 // <string>
11 // we get this comparison "for free" because the string implicitly converts to the string_view
13 #include <string>
14 #include <cassert>
16 #include "test_macros.h"
17 #include "min_allocator.h"
19 template <class S, class SV>
20 TEST_CONSTEXPR_CXX20 void test(const S& lhs, SV rhs, bool x) {
21 assert((lhs != rhs) == x);
24 template <class S>
25 TEST_CONSTEXPR_CXX20 void test_string() {
26 typedef std::string_view SV;
27 test(S(""), SV(""), false);
28 test(S(""), SV("abcde"), true);
29 test(S(""), SV("abcdefghij"), true);
30 test(S(""), SV("abcdefghijklmnopqrst"), true);
31 test(S("abcde"), SV(""), true);
32 test(S("abcde"), SV("abcde"), false);
33 test(S("abcde"), SV("abcdefghij"), true);
34 test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
35 test(S("abcdefghij"), SV(""), true);
36 test(S("abcdefghij"), SV("abcde"), true);
37 test(S("abcdefghij"), SV("abcdefghij"), false);
38 test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
39 test(S("abcdefghijklmnopqrst"), SV(""), true);
40 test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
41 test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
42 test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
45 TEST_CONSTEXPR_CXX20 bool test() {
46 test_string<std::string>();
47 #if TEST_STD_VER >= 11
48 test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
49 #endif
51 return true;
54 int main(int, char**) {
55 test();
56 #if TEST_STD_VER > 17
57 static_assert(test());
58 #endif
60 return 0;