1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // we get this comparison "for free" because the string implicitly converts to the string_view
17 #include "min_allocator.h"
19 template <class S, class SV>
21 test(const S& lhs, SV rhs, bool x)
23 assert((lhs == rhs) == x);
29 typedef std::string S;
30 typedef std::string_view SV;
31 test(S(""), SV(""), true);
32 test(S(""), SV("abcde"), false);
33 test(S(""), SV("abcdefghij"), false);
34 test(S(""), SV("abcdefghijklmnopqrst"), false);
35 test(S("abcde"), SV(""), false);
36 test(S("abcde"), SV("abcde"), true);
37 test(S("abcde"), SV("abcdefghij"), false);
38 test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
39 test(S("abcdefghij"), SV(""), false);
40 test(S("abcdefghij"), SV("abcde"), false);
41 test(S("abcdefghij"), SV("abcdefghij"), true);
42 test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
43 test(S("abcdefghijklmnopqrst"), SV(""), false);
44 test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
45 test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
46 test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
48 #if TEST_STD_VER >= 11
50 typedef std::basic_string <char, std::char_traits<char>, min_allocator<char>> S;
51 typedef std::basic_string_view<char, std::char_traits<char>> SV;
52 test(S(""), SV(""), true);
53 test(S(""), SV("abcde"), false);
54 test(S(""), SV("abcdefghij"), false);
55 test(S(""), SV("abcdefghijklmnopqrst"), false);
56 test(S("abcde"), SV(""), false);
57 test(S("abcde"), SV("abcde"), true);
58 test(S("abcde"), SV("abcdefghij"), false);
59 test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
60 test(S("abcdefghij"), SV(""), false);
61 test(S("abcdefghij"), SV("abcde"), false);
62 test(S("abcdefghij"), SV("abcdefghij"), true);
63 test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
64 test(S("abcdefghijklmnopqrst"), SV(""), false);
65 test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
66 test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
67 test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);