• 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 basic_string<charT,traits,Allocator>& lhs,
13 //                   basic_string_view<charT,traits> rhs);
14 //   bool operator<=(basic_string_view<charT,traits> lhs,
15 //            const basic_string<charT,traits,Allocator>&  rhs);
16 
17 #include <string_view>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 
22 template <class S>
23 void
test(const S & lhs,const typename S::value_type * rhs,bool x,bool y)24 test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
25 {
26     assert((lhs <= rhs) == x);
27     assert((rhs <= lhs) == y);
28 }
29 
main(int,char **)30 int main(int, char**)
31 {
32     {
33     typedef std::string_view S;
34     test(S(""), "", true, true);
35     test(S(""), "abcde", true, false);
36     test(S(""), "abcdefghij", true, false);
37     test(S(""), "abcdefghijklmnopqrst", true, false);
38     test(S("abcde"), "", false, true);
39     test(S("abcde"), "abcde", true, true);
40     test(S("abcde"), "abcdefghij", true, false);
41     test(S("abcde"), "abcdefghijklmnopqrst", true, false);
42     test(S("abcdefghij"), "", false, true);
43     test(S("abcdefghij"), "abcde", false, true);
44     test(S("abcdefghij"), "abcdefghij", true, true);
45     test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
46     test(S("abcdefghijklmnopqrst"), "", false, true);
47     test(S("abcdefghijklmnopqrst"), "abcde", false, true);
48     test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
49     test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
50     }
51 
52   return 0;
53 }
54