Home | History | Annotate | Download | only in string.view.comparison
      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 // template<class charT, class traits, class Allocator>
     13 //   bool operator==(const charT* lhs, const basic_string<charT,traits> rhs);
     14 // template<class charT, class traits, class Allocator>
     15 //   bool operator==(const basic_string_view<charT,traits> lhs, const CharT* rhs);
     16 
     17 #include <experimental/string_view>
     18 #include <cassert>
     19 
     20 #if _LIBCPP_STD_VER > 11
     21 
     22 template <class S>
     23 void
     24 test(const std::string &lhs, S rhs, bool x)
     25 {
     26     assert((lhs == rhs) == x);
     27     assert((rhs == lhs) == x);
     28 }
     29 
     30 int main()
     31 {
     32     {
     33     typedef std::experimental::string_view S;
     34     test("", S(""), true);
     35     test("", S("abcde"), false);
     36     test("", S("abcdefghij"), false);
     37     test("", S("abcdefghijklmnopqrst"), false);
     38     test("abcde", S(""), false);
     39     test("abcde", S("abcde"), true);
     40     test("abcde", S("abcdefghij"), false);
     41     test("abcde", S("abcdefghijklmnopqrst"), false);
     42     test("abcdefghij", S(""), false);
     43     test("abcdefghij", S("abcde"), false);
     44     test("abcdefghij", S("abcdefghij"), true);
     45     test("abcdefghij", S("abcdefghijklmnopqrst"), false);
     46     test("abcdefghijklmnopqrst", S(""), false);
     47     test("abcdefghijklmnopqrst", S("abcde"), false);
     48     test("abcdefghijklmnopqrst", S("abcdefghij"), false);
     49     test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
     50     }
     51 }
     52 #else
     53 int main () {}
     54 #endif
     55