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(""), "", false, false);
35 test(S(""), "abcde", false, true);
36 test(S(""), "abcdefghij", false, true);
37 test(S(""), "abcdefghijklmnopqrst", false, true);
38 test(S("abcde"), "", true, false);
39 test(S("abcde"), "abcde", false, false);
40 test(S("abcde"), "abcdefghij", false, true);
41 test(S("abcde"), "abcdefghijklmnopqrst", false, true);
42 test(S("abcdefghij"), "", true, false);
43 test(S("abcdefghij"), "abcde", true, false);
44 test(S("abcdefghij"), "abcdefghij", false, false);
45 test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
46 test(S("abcdefghijklmnopqrst"), "", true, false);
47 test(S("abcdefghijklmnopqrst"), "abcde", true, false);
48 test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
49 test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
50 }
51
52 return 0;
53 }
54