OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 CFX_WideStringC wide_string_c3(L"hellod"); | 76 CFX_WideStringC wide_string_c3(L"hellod"); |
77 ASSERT_FALSE(wide_string == wide_string_c1); | 77 ASSERT_FALSE(wide_string == wide_string_c1); |
78 ASSERT_FALSE(wide_string == wide_string_c2); | 78 ASSERT_FALSE(wide_string == wide_string_c2); |
79 ASSERT_FALSE(wide_string == wide_string_c3); | 79 ASSERT_FALSE(wide_string == wide_string_c3); |
80 ASSERT_FALSE(wide_string_c1 == wide_string); | 80 ASSERT_FALSE(wide_string_c1 == wide_string); |
81 ASSERT_FALSE(wide_string_c2 == wide_string); | 81 ASSERT_FALSE(wide_string_c2 == wide_string); |
82 ASSERT_FALSE(wide_string_c3 == wide_string); | 82 ASSERT_FALSE(wide_string_c3 == wide_string); |
83 | 83 |
84 const wchar_t* c_string_same1 = L"hello"; | 84 const wchar_t* c_string_same1 = L"hello"; |
85 ASSERT_TRUE(wide_string == c_string_same1); | 85 ASSERT_TRUE(wide_string == c_string_same1); |
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(c_string_same1 == wide_string); | 86 ASSERT_TRUE(c_string_same1 == wide_string); |
90 #endif | |
91 | 87 |
92 const wchar_t* c_string1 = L"he"; | 88 const wchar_t* c_string1 = L"he"; |
93 const wchar_t* c_string2 = L"hellp"; | 89 const wchar_t* c_string2 = L"hellp"; |
94 const wchar_t* c_string3 = L"hellod"; | 90 const wchar_t* c_string3 = L"hellod"; |
95 ASSERT_FALSE(wide_string == c_string1); | 91 ASSERT_FALSE(wide_string == c_string1); |
96 ASSERT_FALSE(wide_string == c_string2); | 92 ASSERT_FALSE(wide_string == c_string2); |
97 ASSERT_FALSE(wide_string == c_string3); | 93 ASSERT_FALSE(wide_string == c_string3); |
98 #if 0 | |
99 // See above TODO. | |
100 ASSERT_FALSE(c_string1 == wide_string); | 94 ASSERT_FALSE(c_string1 == wide_string); |
101 ASSERT_FALSE(c_string2 == wide_string); | 95 ASSERT_FALSE(c_string2 == wide_string); |
102 ASSERT_FALSE(c_string3 == wide_string); | 96 ASSERT_FALSE(c_string3 == wide_string); |
103 #endif | |
104 } | 97 } |
105 | 98 |
106 TEST(fxcrt, WideStringOperatorNE) { | 99 TEST(fxcrt, WideStringOperatorNE) { |
107 CFX_WideString wide_string(L"hello"); | 100 CFX_WideString wide_string(L"hello"); |
108 ASSERT_FALSE(wide_string != wide_string); | 101 ASSERT_FALSE(wide_string != wide_string); |
109 | 102 |
110 CFX_WideString wide_string_same1(L"hello"); | 103 CFX_WideString wide_string_same1(L"hello"); |
111 ASSERT_FALSE(wide_string != wide_string_same1); | 104 ASSERT_FALSE(wide_string != wide_string_same1); |
112 ASSERT_FALSE(wide_string_same1 != wide_string); | 105 ASSERT_FALSE(wide_string_same1 != wide_string); |
113 | 106 |
(...skipping 20 matching lines...) Expand all Loading... |
134 CFX_WideStringC wide_string_c3(L"hellod"); | 127 CFX_WideStringC wide_string_c3(L"hellod"); |
135 ASSERT_TRUE(wide_string != wide_string_c1); | 128 ASSERT_TRUE(wide_string != wide_string_c1); |
136 ASSERT_TRUE(wide_string != wide_string_c2); | 129 ASSERT_TRUE(wide_string != wide_string_c2); |
137 ASSERT_TRUE(wide_string != wide_string_c3); | 130 ASSERT_TRUE(wide_string != wide_string_c3); |
138 ASSERT_TRUE(wide_string_c1 != wide_string); | 131 ASSERT_TRUE(wide_string_c1 != wide_string); |
139 ASSERT_TRUE(wide_string_c2 != wide_string); | 132 ASSERT_TRUE(wide_string_c2 != wide_string); |
140 ASSERT_TRUE(wide_string_c3 != wide_string); | 133 ASSERT_TRUE(wide_string_c3 != wide_string); |
141 | 134 |
142 const wchar_t* c_string_same1 = L"hello"; | 135 const wchar_t* c_string_same1 = L"hello"; |
143 ASSERT_FALSE(wide_string != c_string_same1); | 136 ASSERT_FALSE(wide_string != c_string_same1); |
144 #if 0 | |
145 // See above TODO. | |
146 ASSERT_FALSE(c_string_same1 != wide_string); | 137 ASSERT_FALSE(c_string_same1 != wide_string); |
147 #endif | 138 |
148 const wchar_t* c_string1 = L"he"; | 139 const wchar_t* c_string1 = L"he"; |
149 const wchar_t* c_string2 = L"hellp"; | 140 const wchar_t* c_string2 = L"hellp"; |
150 const wchar_t* c_string3 = L"hellod"; | 141 const wchar_t* c_string3 = L"hellod"; |
151 ASSERT_TRUE(wide_string != c_string1); | 142 ASSERT_TRUE(wide_string != c_string1); |
152 ASSERT_TRUE(wide_string != c_string2); | 143 ASSERT_TRUE(wide_string != c_string2); |
153 ASSERT_TRUE(wide_string != c_string3); | 144 ASSERT_TRUE(wide_string != c_string3); |
154 #if 0 | 145 |
155 // See above TODO. | |
156 ASSERT_TRUE(c_string1 != wide_string); | 146 ASSERT_TRUE(c_string1 != wide_string); |
157 ASSERT_TRUE(c_string2 != wide_string); | 147 ASSERT_TRUE(c_string2 != wide_string); |
158 ASSERT_TRUE(c_string3 != wide_string); | 148 ASSERT_TRUE(c_string3 != wide_string); |
159 #endif | |
160 } | 149 } |
161 | 150 |
162 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) | 151 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) |
163 | 152 |
164 TEST(fxcrt, WideStringUTF16LE_Encode) { | 153 TEST(fxcrt, WideStringUTF16LE_Encode) { |
165 struct UTF16LEEncodeCase { | 154 struct UTF16LEEncodeCase { |
166 CFX_WideString ws; | 155 CFX_WideString ws; |
167 CFX_ByteString bs; | 156 CFX_ByteString bs; |
168 } utf16le_encode_cases[] = { | 157 } utf16le_encode_cases[] = { |
169 { L"", ByteStringLiteral("\0\0") }, | 158 { L"", ByteStringLiteral("\0\0") }, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 CFX_WideString wide_string1(L"he"); | 238 CFX_WideString wide_string1(L"he"); |
250 CFX_WideString wide_string2(L"hellp"); | 239 CFX_WideString wide_string2(L"hellp"); |
251 CFX_WideString wide_string3(L"hellod"); | 240 CFX_WideString wide_string3(L"hellod"); |
252 ASSERT_FALSE(wide_string_c == wide_string1); | 241 ASSERT_FALSE(wide_string_c == wide_string1); |
253 ASSERT_FALSE(wide_string_c == wide_string2); | 242 ASSERT_FALSE(wide_string_c == wide_string2); |
254 ASSERT_FALSE(wide_string_c == wide_string3); | 243 ASSERT_FALSE(wide_string_c == wide_string3); |
255 ASSERT_FALSE(wide_string1 == wide_string_c); | 244 ASSERT_FALSE(wide_string1 == wide_string_c); |
256 ASSERT_FALSE(wide_string2 == wide_string_c); | 245 ASSERT_FALSE(wide_string2 == wide_string_c); |
257 ASSERT_FALSE(wide_string3 == wide_string_c); | 246 ASSERT_FALSE(wide_string3 == wide_string_c); |
258 | 247 |
259 #if 0 | |
260 // TODO(tsepez): ambiguos overload prevents compilation | |
261 const wchar_t* c_string_same1 = L"hello"; | 248 const wchar_t* c_string_same1 = L"hello"; |
262 ASSERT_TRUE(wide_string_c == c_string_same1); | 249 ASSERT_TRUE(wide_string_c == c_string_same1); |
263 ASSERT_TRUE(c_string_same1 == wide_string_c); | 250 ASSERT_TRUE(c_string_same1 == wide_string_c); |
264 | 251 |
265 const wchar_t* c_string1 = L"he"; | 252 const wchar_t* c_string1 = L"he"; |
266 const wchar_t* c_string2 = L"hellp"; | 253 const wchar_t* c_string2 = L"hellp"; |
267 const wchar_t* c_string3 = L"hellod"; | 254 const wchar_t* c_string3 = L"hellod"; |
268 ASSERT_FALSE(wide_string_c == c_string1); | 255 ASSERT_FALSE(wide_string_c == c_string1); |
269 ASSERT_FALSE(wide_string_c == c_string2); | 256 ASSERT_FALSE(wide_string_c == c_string2); |
270 ASSERT_FALSE(wide_string_c == c_string3); | 257 ASSERT_FALSE(wide_string_c == c_string3); |
271 | 258 |
272 ASSERT_FALSE(c_string1 == wide_string_c); | 259 ASSERT_FALSE(c_string1 == wide_string_c); |
273 ASSERT_FALSE(c_string2 == wide_string_c); | 260 ASSERT_FALSE(c_string2 == wide_string_c); |
274 ASSERT_FALSE(c_string3 == wide_string_c); | 261 ASSERT_FALSE(c_string3 == wide_string_c); |
275 #endif | |
276 } | 262 } |
277 | 263 |
278 TEST(fxcrt, WideStringCOperatorNE) { | 264 TEST(fxcrt, WideStringCOperatorNE) { |
279 CFX_WideStringC wide_string_c(L"hello"); | 265 CFX_WideStringC wide_string_c(L"hello"); |
280 ASSERT_FALSE(wide_string_c != wide_string_c); | 266 ASSERT_FALSE(wide_string_c != wide_string_c); |
281 | 267 |
282 CFX_WideStringC wide_string_c_same1(L"hello"); | 268 CFX_WideStringC wide_string_c_same1(L"hello"); |
283 ASSERT_FALSE(wide_string_c != wide_string_c_same1); | 269 ASSERT_FALSE(wide_string_c != wide_string_c_same1); |
284 ASSERT_FALSE(wide_string_c_same1 != wide_string_c); | 270 ASSERT_FALSE(wide_string_c_same1 != wide_string_c); |
285 | 271 |
(...skipping 18 matching lines...) Expand all Loading... |
304 CFX_WideString wide_string1(L"he"); | 290 CFX_WideString wide_string1(L"he"); |
305 CFX_WideString wide_string2(L"hellp"); | 291 CFX_WideString wide_string2(L"hellp"); |
306 CFX_WideString wide_string3(L"hellod"); | 292 CFX_WideString wide_string3(L"hellod"); |
307 ASSERT_TRUE(wide_string_c != wide_string1); | 293 ASSERT_TRUE(wide_string_c != wide_string1); |
308 ASSERT_TRUE(wide_string_c != wide_string2); | 294 ASSERT_TRUE(wide_string_c != wide_string2); |
309 ASSERT_TRUE(wide_string_c != wide_string3); | 295 ASSERT_TRUE(wide_string_c != wide_string3); |
310 ASSERT_TRUE(wide_string1 != wide_string_c); | 296 ASSERT_TRUE(wide_string1 != wide_string_c); |
311 ASSERT_TRUE(wide_string2 != wide_string_c); | 297 ASSERT_TRUE(wide_string2 != wide_string_c); |
312 ASSERT_TRUE(wide_string3 != wide_string_c); | 298 ASSERT_TRUE(wide_string3 != wide_string_c); |
313 | 299 |
314 #if 0 | |
315 // See above TODO. | |
316 const wchar_t* c_string_same1 = L"hello"; | 300 const wchar_t* c_string_same1 = L"hello"; |
317 ASSERT_FALSE(wide_string_c != c_string_same1); | 301 ASSERT_FALSE(wide_string_c != c_string_same1); |
318 ASSERT_FALSE(c_string_same1 != wide_string_c); | 302 ASSERT_FALSE(c_string_same1 != wide_string_c); |
319 | 303 |
320 const wchar_t* c_string1 = L"he"; | 304 const wchar_t* c_string1 = L"he"; |
321 const wchar_t* c_string2 = L"hellp"; | 305 const wchar_t* c_string2 = L"hellp"; |
322 const wchar_t* c_string3 = L"hellod"; | 306 const wchar_t* c_string3 = L"hellod"; |
323 ASSERT_TRUE(wide_string_c != c_string1); | 307 ASSERT_TRUE(wide_string_c != c_string1); |
324 ASSERT_TRUE(wide_string_c != c_string2); | 308 ASSERT_TRUE(wide_string_c != c_string2); |
325 ASSERT_TRUE(wide_string_c != c_string3); | 309 ASSERT_TRUE(wide_string_c != c_string3); |
326 | 310 |
327 ASSERT_TRUE(c_string1 != wide_string_c); | 311 ASSERT_TRUE(c_string1 != wide_string_c); |
328 ASSERT_TRUE(c_string2 != wide_string_c); | 312 ASSERT_TRUE(c_string2 != wide_string_c); |
329 ASSERT_TRUE(c_string3 != wide_string_c); | 313 ASSERT_TRUE(c_string3 != wide_string_c); |
330 #endif | |
331 } | 314 } |
OLD | NEW |