Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: core/src/fxcrt/fx_basic_wstring_unittest.cpp

Issue 1122573002: Backfill some FX String unit tests for == and !=. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@retained_strings
Patch Set: rebased Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "../../../testing/fx_string_testhelpers.h" 6 #include "../../../testing/fx_string_testhelpers.h"
7 #include "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 8
9 TEST(fxcrt, WideStringOperatorSubscript) { 9 TEST(fxcrt, WideStringOperatorSubscript) {
10 // CFX_WideString includes the NUL terminator for non-empty strings. 10 // CFX_WideString includes the NUL terminator for non-empty strings.
(...skipping 27 matching lines...) Expand all
38 EXPECT_TRUE(a < abc); 38 EXPECT_TRUE(a < abc);
39 EXPECT_FALSE(abc < a); 39 EXPECT_FALSE(abc < a);
40 40
41 EXPECT_TRUE(a < def); 41 EXPECT_TRUE(a < def);
42 EXPECT_FALSE(def < a); 42 EXPECT_FALSE(def < a);
43 43
44 EXPECT_TRUE(abc < def); 44 EXPECT_TRUE(abc < def);
45 EXPECT_FALSE(def < abc); 45 EXPECT_FALSE(def < abc);
46 } 46 }
47 47
48 TEST(fxcrt, WideStringOperatorEQ) {
49 CFX_WideString wideString(L"hello");
50 ASSERT_TRUE(wideString == wideString);
51
52 CFX_WideString wideStringSame1(L"hello");
53 ASSERT_TRUE(wideString == wideStringSame1);
54 ASSERT_TRUE(wideStringSame1 == wideString);
55
56 CFX_WideString wideStringSame2(wideString);
57 ASSERT_TRUE(wideString == wideStringSame2);
58 ASSERT_TRUE(wideStringSame2 == wideString);
59
60 CFX_WideString wideString1(L"he");
61 CFX_WideString wideString2(L"hellp");
62 CFX_WideString wideString3(L"hellod");
63 ASSERT_FALSE(wideString == wideString1);
64 ASSERT_FALSE(wideString == wideString2);
65 ASSERT_FALSE(wideString == wideString3);
66 ASSERT_FALSE(wideString1 == wideString);
67 ASSERT_FALSE(wideString2 == wideString);
68 ASSERT_FALSE(wideString3 == wideString);
69
70 CFX_WideStringC wideStringCSame1(L"hello");
71 ASSERT_TRUE(wideString == wideStringCSame1);
72 ASSERT_TRUE(wideStringCSame1 == wideString);
73
74 CFX_WideStringC wideStringC1(L"he");
75 CFX_WideStringC wideStringC2(L"hellp");
76 CFX_WideStringC wideStringC3(L"hellod");
77 ASSERT_FALSE(wideString == wideStringC1);
78 ASSERT_FALSE(wideString == wideStringC2);
79 ASSERT_FALSE(wideString == wideStringC3);
80 ASSERT_FALSE(wideStringC1 == wideString);
81 ASSERT_FALSE(wideStringC2 == wideString);
82 ASSERT_FALSE(wideStringC3 == wideString);
83
84 const wchar_t* cStringSame1 = L"hello";
85 ASSERT_TRUE(wideString == cStringSame1);
86 #if 0
87 // TODO(tsepez): Missing operator - there's a prototype but no actual
88 // implementation (at least we already removed implicit c_str() casting).
89 ASSERT_TRUE(cStringSame1 == wideString);
90 #endif
91
92 const wchar_t* cString1 = L"he";
93 const wchar_t* cString2 = L"hellp";
94 const wchar_t* cString3 = L"hellod";
95 ASSERT_FALSE(wideString == cString1);
96 ASSERT_FALSE(wideString == cString2);
97 ASSERT_FALSE(wideString == cString3);
98 #if 0
99 // See above TODO.
100 ASSERT_FALSE(cString1 == wideString);
101 ASSERT_FALSE(cString2 == wideString);
102 ASSERT_FALSE(cString3 == wideString);
103 #endif
104 }
105
106 TEST(fxcrt, WideStringOperatorNE) {
107 CFX_WideString wideString(L"hello");
108 ASSERT_FALSE(wideString != wideString);
109
110 CFX_WideString wideStringSame1(L"hello");
111 ASSERT_FALSE(wideString != wideStringSame1);
112 ASSERT_FALSE(wideStringSame1 != wideString);
113
114 CFX_WideString wideStringSame2(wideString);
115 ASSERT_FALSE(wideString != wideStringSame2);
116 ASSERT_FALSE(wideStringSame2 != wideString);
117
118 CFX_WideString wideString1(L"he");
119 CFX_WideString wideString2(L"hellp");
120 CFX_WideString wideString3(L"hellod");
121 ASSERT_TRUE(wideString != wideString1);
122 ASSERT_TRUE(wideString != wideString2);
123 ASSERT_TRUE(wideString != wideString3);
124 ASSERT_TRUE(wideString1 != wideString);
125 ASSERT_TRUE(wideString2 != wideString);
126 ASSERT_TRUE(wideString3 != wideString);
127
128 CFX_WideStringC wideStringCSame1(L"hello");
129 ASSERT_FALSE(wideString != wideStringCSame1);
130 ASSERT_FALSE(wideStringCSame1 != wideString);
131
132 CFX_WideStringC wideStringC1(L"he");
133 CFX_WideStringC wideStringC2(L"hellp");
134 CFX_WideStringC wideStringC3(L"hellod");
135 ASSERT_TRUE(wideString != wideStringC1);
136 ASSERT_TRUE(wideString != wideStringC2);
137 ASSERT_TRUE(wideString != wideStringC3);
138 ASSERT_TRUE(wideStringC1 != wideString);
139 ASSERT_TRUE(wideStringC2 != wideString);
140 ASSERT_TRUE(wideStringC3 != wideString);
141
142 const wchar_t* cStringSame1 = L"hello";
143 ASSERT_FALSE(wideString != cStringSame1);
144 #if 0
145 // See above TODO.
146 ASSERT_FALSE(cStringSame1 != wideString);
147 #endif
148 const wchar_t* cString1 = L"he";
149 const wchar_t* cString2 = L"hellp";
150 const wchar_t* cString3 = L"hellod";
151 ASSERT_TRUE(wideString != cString1);
152 ASSERT_TRUE(wideString != cString2);
153 ASSERT_TRUE(wideString != cString3);
154 #if 0
155 // See above TODO.
156 ASSERT_TRUE(cString1 != wideString);
157 ASSERT_TRUE(cString2 != wideString);
158 ASSERT_TRUE(cString3 != wideString);
159 #endif
160 }
161
48 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) 162 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str))
49 163
50 TEST(fxcrt, WideStringUTF16LE_Encode) { 164 TEST(fxcrt, WideStringUTF16LE_Encode) {
51 struct UTF16LEEncodeCase { 165 struct UTF16LEEncodeCase {
52 CFX_WideString ws; 166 CFX_WideString ws;
53 CFX_ByteString bs; 167 CFX_ByteString bs;
54 } utf16le_encode_cases[] = { 168 } utf16le_encode_cases[] = {
55 { L"", ByteStringLiteral("\0\0") }, 169 { L"", ByteStringLiteral("\0\0") },
56 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") }, 170 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") },
57 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") }, 171 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") },
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 EXPECT_TRUE(a < abc); 213 EXPECT_TRUE(a < abc);
100 EXPECT_FALSE(abc < a); 214 EXPECT_FALSE(abc < a);
101 215
102 EXPECT_TRUE(a < def); 216 EXPECT_TRUE(a < def);
103 EXPECT_FALSE(def < a); 217 EXPECT_FALSE(def < a);
104 218
105 EXPECT_TRUE(abc < def); 219 EXPECT_TRUE(abc < def);
106 EXPECT_FALSE(def < abc); 220 EXPECT_FALSE(def < abc);
107 } 221 }
108 222
OLDNEW
« core/src/fxcrt/fx_basic_bstring_unittest.cpp ('K') | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698