1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <string> 11 12// we get this comparison "for free" because the string implicitly converts to the string_view 13 14#include <string> 15#include <cassert> 16 17#include "min_allocator.h" 18 19template <class S, class SV> 20void 21test(SV lhs, const S& rhs, bool x) 22{ 23 assert((lhs == rhs) == x); 24} 25 26int main() 27{ 28 { 29 typedef std::string S; 30 typedef std::string_view SV; 31 test(SV(""), S(""), true); 32 test(SV(""), S("abcde"), false); 33 test(SV(""), S("abcdefghij"), false); 34 test(SV(""), S("abcdefghijklmnopqrst"), false); 35 test(SV("abcde"), S(""), false); 36 test(SV("abcde"), S("abcde"), true); 37 test(SV("abcde"), S("abcdefghij"), false); 38 test(SV("abcde"), S("abcdefghijklmnopqrst"), false); 39 test(SV("abcdefghij"), S(""), false); 40 test(SV("abcdefghij"), S("abcde"), false); 41 test(SV("abcdefghij"), S("abcdefghij"), true); 42 test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false); 43 test(SV("abcdefghijklmnopqrst"), S(""), false); 44 test(SV("abcdefghijklmnopqrst"), S("abcde"), false); 45 test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false); 46 test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); 47 } 48#if TEST_STD_VER >= 11 49 { 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(SV(""), S(""), true); 53 test(SV(""), S("abcde"), false); 54 test(SV(""), S("abcdefghij"), false); 55 test(SV(""), S("abcdefghijklmnopqrst"), false); 56 test(SV("abcde"), S(""), false); 57 test(SV("abcde"), S("abcde"), true); 58 test(SV("abcde"), S("abcdefghij"), false); 59 test(SV("abcde"), S("abcdefghijklmnopqrst"), false); 60 test(SV("abcdefghij"), S(""), false); 61 test(SV("abcdefghij"), S("abcde"), false); 62 test(SV("abcdefghij"), S("abcdefghij"), true); 63 test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false); 64 test(SV("abcdefghijklmnopqrst"), S(""), false); 65 test(SV("abcdefghijklmnopqrst"), S("abcde"), false); 66 test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false); 67 test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); 68 } 69#endif 70} 71