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_view>
10
11 // template<class charT, class traits, class Allocator>
12 // constexpr bool operator!=(const basic_string_view<charT,traits> lhs,
13 // const basic_string_view<charT,traits> rhs);
14
15 #include <string_view>
16 #include <cassert>
17
18 #include "test_macros.h"
19 #include "constexpr_char_traits.h"
20
21 template <class S>
22 void
test(S lhs,S rhs,bool x)23 test(S lhs, S rhs, bool x)
24 {
25 assert((lhs != rhs) == x);
26 assert((rhs != lhs) == x);
27 }
28
main(int,char **)29 int main(int, char**)
30 {
31 {
32 typedef std::string_view S;
33 test(S(""), S(""), false);
34 test(S(""), S("abcde"), true);
35 test(S(""), S("abcdefghij"), true);
36 test(S(""), S("abcdefghijklmnopqrst"), true);
37 test(S("abcde"), S(""), true);
38 test(S("abcde"), S("abcde"), false);
39 test(S("abcde"), S("abcdefghij"), true);
40 test(S("abcde"), S("abcdefghijklmnopqrst"), true);
41 test(S("abcdefghij"), S(""), true);
42 test(S("abcdefghij"), S("abcde"), true);
43 test(S("abcdefghij"), S("abcdefghij"), false);
44 test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
45 test(S("abcdefghijklmnopqrst"), S(""), true);
46 test(S("abcdefghijklmnopqrst"), S("abcde"), true);
47 test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
48 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
49 }
50
51 #if TEST_STD_VER > 11
52 {
53 typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
54 constexpr SV sv1;
55 constexpr SV sv2;
56 constexpr SV sv3 { "abcde", 5 };
57 static_assert (!( sv1 != sv2), "" );
58 static_assert ( sv1 != sv3, "" );
59 }
60 #endif
61
62 return 0;
63 }
64