]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / strings / basic.string / string.nonmembers / string_operator== / string_pointer.pass.cpp
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, const charT* rhs);
14
15 #include <string>
16 #include <cassert>
17
18 #include "min_allocator.h"
19
20 template <class S>
21 void
22 test(const S& lhs, const typename S::value_type* rhs, bool x)
23 {
24     assert((lhs == rhs) == x);
25 }
26
27 int main()
28 {
29     {
30     typedef std::string S;
31     test(S(""), "", true);
32     test(S(""), "abcde", false);
33     test(S(""), "abcdefghij", false);
34     test(S(""), "abcdefghijklmnopqrst", false);
35     test(S("abcde"), "", false);
36     test(S("abcde"), "abcde", true);
37     test(S("abcde"), "abcdefghij", false);
38     test(S("abcde"), "abcdefghijklmnopqrst", false);
39     test(S("abcdefghij"), "", false);
40     test(S("abcdefghij"), "abcde", false);
41     test(S("abcdefghij"), "abcdefghij", true);
42     test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
43     test(S("abcdefghijklmnopqrst"), "", false);
44     test(S("abcdefghijklmnopqrst"), "abcde", false);
45     test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
46     test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
47     }
48 #if TEST_STD_VER >= 11
49     {
50     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
51     test(S(""), "", true);
52     test(S(""), "abcde", false);
53     test(S(""), "abcdefghij", false);
54     test(S(""), "abcdefghijklmnopqrst", false);
55     test(S("abcde"), "", false);
56     test(S("abcde"), "abcde", true);
57     test(S("abcde"), "abcdefghij", false);
58     test(S("abcde"), "abcdefghijklmnopqrst", false);
59     test(S("abcdefghij"), "", false);
60     test(S("abcdefghij"), "abcde", false);
61     test(S("abcdefghij"), "abcdefghij", true);
62     test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
63     test(S("abcdefghijklmnopqrst"), "", false);
64     test(S("abcdefghijklmnopqrst"), "abcde", false);
65     test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
66     test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
67     }
68 #endif
69 }