• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //===----------------------------------------------------------------------===//
8 
9 // <string>
10 
11 // template<class charT, class traits, class Allocator>
12 //   bool operator==(const charT* lhs, const basic_string<charT,traits> rhs);
13 // template<class charT, class traits, class Allocator>
14 //   bool operator==(const basic_string_view<charT,traits> lhs, const CharT* rhs);
15 
16 #include <string_view>
17 #include <string>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 
22 template <class S>
23 void
test(const std::string & lhs,S rhs,bool x)24 test(const std::string &lhs, S rhs, bool x)
25 {
26     assert((lhs == rhs) == x);
27     assert((rhs == lhs) == x);
28 }
29 
main(int,char **)30 int main(int, char**)
31 {
32     {
33     typedef std::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   return 0;
53 }
54