[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / strings / string.view / string.view.comparison / ople.string_view.string_view.pass.cpp
blob267550ad5ea630a6a480514d7ce28f7263587ef2
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 //===----------------------------------------------------------------------===//
9 // <string>
11 // template<class charT, class traits>
12 // constexpr bool operator<=(basic_string_view<charT,traits> lhs,
13 // basic_string_view<charT,traits> rhs);
15 #include <string_view>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "constexpr_char_traits.h"
21 template <class S>
22 void
23 test(const S& lhs, const S& rhs, bool x, bool y)
25 assert((lhs <= rhs) == x);
26 assert((rhs <= lhs) == y);
29 int main(int, char**)
32 typedef std::string_view S;
33 test(S(""), S(""), true, true);
34 test(S(""), S("abcde"), true, false);
35 test(S(""), S("abcdefghij"), true, false);
36 test(S(""), S("abcdefghijklmnopqrst"), true, false);
37 test(S("abcde"), S(""), false, true);
38 test(S("abcde"), S("abcde"), true, true);
39 test(S("abcde"), S("abcdefghij"), true, false);
40 test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
41 test(S("abcdefghij"), S(""), false, true);
42 test(S("abcdefghij"), S("abcde"), false, true);
43 test(S("abcdefghij"), S("abcdefghij"), true, true);
44 test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
45 test(S("abcdefghijklmnopqrst"), S(""), false, true);
46 test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
47 test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
48 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
51 #if TEST_STD_VER > 11
53 typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
54 constexpr SV sv1;
55 constexpr SV sv2 { "abcde", 5 };
57 static_assert ( sv1 <= sv1, "" );
58 static_assert ( sv2 <= sv2, "" );
60 static_assert ( sv1 <= sv2, "" );
61 static_assert (!(sv2 <= sv1), "" );
63 #endif
65 return 0;