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