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_view> 11 12// template<class charT, class traits, class Allocator> 13// constexpr bool operator==(const basic_string_view<charT,traits> lhs, 14// const basic_string_view<charT,traits> rhs); 15 16#include <experimental/string_view> 17#include <cassert> 18 19#include "test_macros.h" 20#include "constexpr_char_traits.hpp" 21 22template <class S> 23void 24test(S lhs, S rhs, bool x) 25{ 26 assert((lhs == rhs) == x); 27 assert((rhs == lhs) == x); 28} 29 30int main() 31{ 32 { 33 typedef std::experimental::string_view S; 34 test(S(""), S(""), true); 35 test(S(""), S("abcde"), false); 36 test(S(""), S("abcdefghij"), false); 37 test(S(""), S("abcdefghijklmnopqrst"), false); 38 test(S("abcde"), S(""), false); 39 test(S("abcde"), S("abcde"), true); 40 test(S("abcde"), S("abcdefghij"), false); 41 test(S("abcde"), S("abcdefghijklmnopqrst"), false); 42 test(S("abcdefghij"), S(""), false); 43 test(S("abcdefghij"), S("abcde"), false); 44 test(S("abcdefghij"), S("abcdefghij"), true); 45 test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); 46 test(S("abcdefghijklmnopqrst"), S(""), false); 47 test(S("abcdefghijklmnopqrst"), S("abcde"), false); 48 test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); 49 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); 50 } 51 52#if TEST_STD_VER > 11 53 { 54 typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV; 55 constexpr SV sv1; 56 constexpr SV sv2; 57 constexpr SV sv3 { "abcde", 5 }; 58 static_assert ( sv1 == sv2, "" ); 59 static_assert (!(sv1 == sv3), "" ); 60 } 61#endif 62} 63