Fix comparison of CFX_ByteString and CFX_WideString against empty literals.
[pdfium.git] / core / src / fxcrt / fx_basic_bstring_unittest.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "../../../testing/fx_string_testhelpers.h"
7 #include "../../include/fxcrt/fx_basic.h"
8
9 TEST(fxcrt, ByteStringOperatorSubscript) {
10     // CFX_ByteString includes the NUL terminator for non-empty strings.
11     CFX_ByteString abc("abc");
12     EXPECT_EQ('a', abc[0]);
13     EXPECT_EQ('b', abc[1]);
14     EXPECT_EQ('c', abc[2]);
15     EXPECT_EQ(0, abc[3]);
16 }
17
18 TEST(fxcrt, ByteStringOperatorLT) {
19     CFX_ByteString empty;
20     CFX_ByteString a("a");
21     CFX_ByteString abc("abc");
22     CFX_ByteString def("def");
23
24     EXPECT_FALSE(empty < empty);
25     EXPECT_FALSE(a < a);
26     EXPECT_FALSE(abc < abc);
27     EXPECT_FALSE(def < def);
28
29     EXPECT_TRUE(empty < a);
30     EXPECT_FALSE(a < empty);
31
32     EXPECT_TRUE(empty < abc);
33     EXPECT_FALSE(abc < empty);
34
35     EXPECT_TRUE(empty < def);
36     EXPECT_FALSE(def < empty);
37
38     EXPECT_TRUE(a < abc);
39     EXPECT_FALSE(abc < a);
40
41     EXPECT_TRUE(a < def);
42     EXPECT_FALSE(def < a);
43
44     EXPECT_TRUE(abc < def);
45     EXPECT_FALSE(def < abc);
46 }
47
48 TEST(fxcrt, ByteStringOperatorEQ) {
49     CFX_ByteString null_string;
50     EXPECT_TRUE(null_string == null_string);
51
52     CFX_ByteString empty_string("");
53     EXPECT_TRUE(empty_string == empty_string);
54     EXPECT_TRUE(empty_string == null_string);
55     EXPECT_TRUE(null_string == empty_string);
56
57     CFX_ByteString deleted_string("hello");
58     deleted_string.Delete(0, 5);
59     EXPECT_TRUE(deleted_string == deleted_string);
60     EXPECT_TRUE(deleted_string == null_string);
61     EXPECT_TRUE(deleted_string == empty_string);
62     EXPECT_TRUE(null_string == deleted_string);
63     EXPECT_TRUE(empty_string == deleted_string);
64
65     CFX_ByteString byte_string("hello");
66     EXPECT_TRUE(byte_string == byte_string);
67     EXPECT_FALSE(byte_string == null_string);
68     EXPECT_FALSE(byte_string == empty_string);
69     EXPECT_FALSE(byte_string == deleted_string);
70     EXPECT_FALSE(null_string == byte_string);
71     EXPECT_FALSE(empty_string == byte_string);
72     EXPECT_FALSE(deleted_string == byte_string);
73
74     CFX_ByteString byte_string_same1("hello");
75     EXPECT_TRUE(byte_string == byte_string_same1);
76     EXPECT_TRUE(byte_string_same1 == byte_string);
77
78     CFX_ByteString byte_string_same2(byte_string);
79     EXPECT_TRUE(byte_string == byte_string_same2);
80     EXPECT_TRUE(byte_string_same2 == byte_string);
81
82     CFX_ByteString byte_string1("he");
83     CFX_ByteString byte_string2("hellp");
84     CFX_ByteString byte_string3("hellod");
85     EXPECT_FALSE(byte_string == byte_string1);
86     EXPECT_FALSE(byte_string == byte_string2);
87     EXPECT_FALSE(byte_string == byte_string3);
88     EXPECT_FALSE(byte_string1 == byte_string);
89     EXPECT_FALSE(byte_string2 == byte_string);
90     EXPECT_FALSE(byte_string3 == byte_string);
91
92     CFX_ByteStringC null_string_c;
93     CFX_ByteStringC empty_string_c("");
94     EXPECT_TRUE(null_string == null_string_c);
95     EXPECT_TRUE(null_string == empty_string_c);
96     EXPECT_TRUE(empty_string == null_string_c);
97     EXPECT_TRUE(empty_string == empty_string_c);
98     EXPECT_TRUE(deleted_string == null_string_c);
99     EXPECT_TRUE(deleted_string == empty_string_c);
100     EXPECT_TRUE(null_string_c == null_string);
101     EXPECT_TRUE(empty_string_c == null_string);
102     EXPECT_TRUE(null_string_c == empty_string);
103     EXPECT_TRUE(empty_string_c == empty_string);
104     EXPECT_TRUE(null_string_c == deleted_string);
105     EXPECT_TRUE(empty_string_c == deleted_string);
106
107     CFX_ByteStringC byte_string_c_same1("hello");
108     EXPECT_TRUE(byte_string == byte_string_c_same1);
109     EXPECT_TRUE(byte_string_c_same1 == byte_string);
110
111     CFX_ByteStringC byte_string_c1("he");
112     CFX_ByteStringC byte_string_c2("hellp");
113     CFX_ByteStringC byte_string_c3("hellod");
114     EXPECT_FALSE(byte_string == byte_string_c1);
115     EXPECT_FALSE(byte_string == byte_string_c2);
116     EXPECT_FALSE(byte_string == byte_string_c3);
117     EXPECT_FALSE(byte_string_c1 == byte_string);
118     EXPECT_FALSE(byte_string_c2 == byte_string);
119     EXPECT_FALSE(byte_string_c3 == byte_string);
120
121     const char* c_null_string = nullptr;
122     const char* c_empty_string = "";
123     EXPECT_TRUE(null_string == c_null_string);
124     EXPECT_TRUE(null_string == c_empty_string);
125     EXPECT_TRUE(empty_string == c_null_string);
126     EXPECT_TRUE(empty_string == c_empty_string);
127     EXPECT_TRUE(deleted_string == c_null_string);
128     EXPECT_TRUE(deleted_string == c_empty_string);
129     EXPECT_TRUE(c_null_string == null_string);
130     EXPECT_TRUE(c_empty_string == null_string);
131     EXPECT_TRUE(c_null_string == empty_string);
132     EXPECT_TRUE(c_empty_string == empty_string);
133     EXPECT_TRUE(c_null_string == deleted_string);
134     EXPECT_TRUE(c_empty_string == deleted_string);
135
136     const char* c_string_same1 = "hello";
137     EXPECT_TRUE(byte_string == c_string_same1);
138     EXPECT_TRUE(c_string_same1 == byte_string);
139
140     const char* c_string1 = "he";
141     const char* c_string2 = "hellp";
142     const char* c_string3 = "hellod";
143     EXPECT_FALSE(byte_string == c_string1);
144     EXPECT_FALSE(byte_string == c_string2);
145     EXPECT_FALSE(byte_string == c_string3);
146     EXPECT_FALSE(c_string1 == byte_string);
147     EXPECT_FALSE(c_string2 == byte_string);
148     EXPECT_FALSE(c_string3 == byte_string);
149 }
150
151 TEST(fxcrt, ByteStringOperatorNE) {
152     CFX_ByteString null_string;
153     EXPECT_FALSE(null_string != null_string);
154
155     CFX_ByteString empty_string("");
156     EXPECT_FALSE(empty_string != empty_string);
157     EXPECT_FALSE(empty_string != null_string);
158     EXPECT_FALSE(null_string != empty_string);
159
160     CFX_ByteString deleted_string("hello");
161     deleted_string.Delete(0, 5);
162     EXPECT_FALSE(deleted_string != deleted_string);
163     EXPECT_FALSE(deleted_string != null_string);
164     EXPECT_FALSE(deleted_string != empty_string);
165     EXPECT_FALSE(deleted_string != deleted_string);
166     EXPECT_FALSE(null_string != deleted_string);
167     EXPECT_FALSE(empty_string != deleted_string);
168     EXPECT_FALSE(deleted_string != deleted_string);
169
170     CFX_ByteString byte_string("hello");
171     EXPECT_FALSE(byte_string != byte_string);
172     EXPECT_TRUE(byte_string != null_string);
173     EXPECT_TRUE(byte_string != empty_string);
174     EXPECT_TRUE(byte_string != deleted_string);
175     EXPECT_TRUE(null_string != byte_string);
176     EXPECT_TRUE(empty_string != byte_string);
177     EXPECT_TRUE(deleted_string != byte_string);
178
179     CFX_ByteString byte_string_same1("hello");
180     EXPECT_FALSE(byte_string != byte_string_same1);
181     EXPECT_FALSE(byte_string_same1 != byte_string);
182
183     CFX_ByteString byte_string_same2(byte_string);
184     EXPECT_FALSE(byte_string != byte_string_same2);
185     EXPECT_FALSE(byte_string_same2 != byte_string);
186
187     CFX_ByteString byte_string1("he");
188     CFX_ByteString byte_string2("hellp");
189     CFX_ByteString byte_string3("hellod");
190     EXPECT_TRUE(byte_string != byte_string1);
191     EXPECT_TRUE(byte_string != byte_string2);
192     EXPECT_TRUE(byte_string != byte_string3);
193     EXPECT_TRUE(byte_string1 != byte_string);
194     EXPECT_TRUE(byte_string2 != byte_string);
195     EXPECT_TRUE(byte_string3 != byte_string);
196
197     CFX_ByteStringC null_string_c;
198     CFX_ByteStringC empty_string_c("");
199     EXPECT_FALSE(null_string != null_string_c);
200     EXPECT_FALSE(null_string != empty_string_c);
201     EXPECT_FALSE(empty_string != null_string_c);
202     EXPECT_FALSE(empty_string != empty_string_c);
203     EXPECT_FALSE(null_string_c != null_string);
204     EXPECT_FALSE(empty_string_c != null_string);
205     EXPECT_FALSE(null_string_c != empty_string);
206     EXPECT_FALSE(empty_string_c != empty_string);
207
208     CFX_ByteStringC byte_string_c_same1("hello");
209     EXPECT_FALSE(byte_string != byte_string_c_same1);
210     EXPECT_FALSE(byte_string_c_same1 != byte_string);
211
212     CFX_ByteStringC byte_string_c1("he");
213     CFX_ByteStringC byte_string_c2("hellp");
214     CFX_ByteStringC byte_string_c3("hellod");
215     EXPECT_TRUE(byte_string != byte_string_c1);
216     EXPECT_TRUE(byte_string != byte_string_c2);
217     EXPECT_TRUE(byte_string != byte_string_c3);
218     EXPECT_TRUE(byte_string_c1 != byte_string);
219     EXPECT_TRUE(byte_string_c2 != byte_string);
220     EXPECT_TRUE(byte_string_c3 != byte_string);
221
222     const char* c_null_string = nullptr;
223     const char* c_empty_string = "";
224     EXPECT_FALSE(null_string != c_null_string);
225     EXPECT_FALSE(null_string != c_empty_string);
226     EXPECT_FALSE(empty_string != c_null_string);
227     EXPECT_FALSE(empty_string != c_empty_string);
228     EXPECT_FALSE(deleted_string != c_null_string);
229     EXPECT_FALSE(deleted_string != c_empty_string);
230     EXPECT_FALSE(c_null_string != null_string);
231     EXPECT_FALSE(c_empty_string != null_string);
232     EXPECT_FALSE(c_null_string != empty_string);
233     EXPECT_FALSE(c_empty_string != empty_string);
234     EXPECT_FALSE(c_null_string != deleted_string);
235     EXPECT_FALSE(c_empty_string != deleted_string);
236
237     const char* c_string_same1 = "hello";
238     EXPECT_FALSE(byte_string != c_string_same1);
239     EXPECT_FALSE(c_string_same1 != byte_string);
240
241     const char* c_string1 = "he";
242     const char* c_string2 = "hellp";
243     const char* c_string3 = "hellod";
244     EXPECT_TRUE(byte_string != c_string1);
245     EXPECT_TRUE(byte_string != c_string2);
246     EXPECT_TRUE(byte_string != c_string3);
247     EXPECT_TRUE(c_string1 != byte_string);
248     EXPECT_TRUE(c_string2 != byte_string);
249     EXPECT_TRUE(c_string3 != byte_string);
250 }
251
252 TEST(fxcrt, ByteStringCNull) {
253   CFX_ByteStringC null_string;
254   EXPECT_EQ(null_string.GetPtr(), nullptr);
255   EXPECT_EQ(null_string.GetLength(), 0);
256   EXPECT_TRUE(null_string.IsEmpty());
257
258   CFX_ByteStringC another_null_string;
259   EXPECT_EQ(null_string, another_null_string);
260
261   CFX_ByteStringC copied_null_string(null_string);
262   EXPECT_EQ(copied_null_string.GetPtr(), nullptr);
263   EXPECT_EQ(copied_null_string.GetLength(), 0);
264   EXPECT_TRUE(copied_null_string.IsEmpty());
265   EXPECT_EQ(null_string, copied_null_string);
266
267   CFX_ByteStringC empty_string("");  // Pointer to NUL, not NULL pointer.
268   EXPECT_NE(empty_string.GetPtr(), nullptr);
269   EXPECT_EQ(empty_string.GetLength(), 0);
270   EXPECT_TRUE(empty_string.IsEmpty());
271   EXPECT_EQ(null_string, empty_string);
272
273   CFX_ByteStringC assigned_null_string("initially not NULL");
274   assigned_null_string = null_string;
275   EXPECT_EQ(assigned_null_string.GetPtr(), nullptr);
276   EXPECT_EQ(assigned_null_string.GetLength(), 0);
277   EXPECT_TRUE(assigned_null_string.IsEmpty());
278   EXPECT_EQ(null_string, assigned_null_string);
279
280   CFX_ByteStringC assigned_nullptr_string("initially not NULL");
281   assigned_nullptr_string = (FX_LPCSTR)nullptr;
282   EXPECT_EQ(assigned_nullptr_string.GetPtr(), nullptr);
283   EXPECT_EQ(assigned_nullptr_string.GetLength(), 0);
284   EXPECT_TRUE(assigned_nullptr_string.IsEmpty());
285   EXPECT_EQ(null_string, assigned_nullptr_string);
286
287   CFX_ByteStringC non_null_string("a");
288   EXPECT_NE(null_string, non_null_string);
289 }
290
291 TEST(fxcrt, ByteStringCNotNull) {
292   CFX_ByteStringC string3("abc");
293   CFX_ByteStringC string6("abcdef");
294   CFX_ByteStringC alternate_string3("abcdef", 3);
295   CFX_ByteStringC embedded_nul_string7("abc\0def", 7);
296   CFX_ByteStringC illegal_string7("abcdef", 7);
297
298   EXPECT_EQ(3, string3.GetLength());
299   EXPECT_EQ(6, string6.GetLength());
300   EXPECT_EQ(3, alternate_string3.GetLength());
301   EXPECT_EQ(7, embedded_nul_string7.GetLength());
302   EXPECT_EQ(7, illegal_string7.GetLength());
303
304   EXPECT_NE(string3, string6);
305   EXPECT_EQ(string3, alternate_string3);
306   EXPECT_NE(string3, embedded_nul_string7);
307   EXPECT_NE(string3, illegal_string7);
308   EXPECT_NE(string6, alternate_string3);
309   EXPECT_NE(string6, embedded_nul_string7);
310   EXPECT_NE(string6, illegal_string7);
311   EXPECT_NE(alternate_string3, embedded_nul_string7);
312   EXPECT_NE(alternate_string3, illegal_string7);
313   EXPECT_NE(embedded_nul_string7, illegal_string7);
314
315   CFX_ByteStringC copied_string3(string3);
316   CFX_ByteStringC copied_alternate_string3(alternate_string3);
317   CFX_ByteStringC copied_embedded_nul_string7(embedded_nul_string7);
318
319   EXPECT_EQ(string3, copied_string3);
320   EXPECT_EQ(alternate_string3, copied_alternate_string3);
321   EXPECT_EQ(embedded_nul_string7, copied_embedded_nul_string7);
322
323   CFX_ByteStringC assigned_string3("intially something else");
324   CFX_ByteStringC assigned_alternate_string3("initally something else");
325   CFX_ByteStringC assigned_ptr_string3("initially something else");
326   CFX_ByteStringC assigned_embedded_nul_string7("initially something else");
327
328   assigned_string3 = string3;
329   assigned_alternate_string3 = alternate_string3;
330   assigned_ptr_string3 = "abc";
331   assigned_embedded_nul_string7 = embedded_nul_string7;
332   EXPECT_EQ(string3, assigned_string3);
333   EXPECT_EQ(alternate_string3, assigned_alternate_string3);
334   EXPECT_EQ(alternate_string3, assigned_ptr_string3);
335   EXPECT_EQ(embedded_nul_string7, assigned_embedded_nul_string7);
336 }
337
338 TEST(fxcrt, ByteStringCFromChar) {
339   CFX_ByteStringC null_string;
340   CFX_ByteStringC lower_a_string("a");
341
342   // Must have lvalues that outlive the corresponding ByteStringC.
343   char nul = '\0';
344   char lower_a = 'a';
345   CFX_ByteStringC nul_string_from_char(nul);
346   CFX_ByteStringC lower_a_string_from_char(lower_a);
347
348   // Pointer to nul, not NULL ptr, hence length 1 ...
349   EXPECT_EQ(1, nul_string_from_char.GetLength());
350   EXPECT_NE(null_string, nul_string_from_char);
351
352   EXPECT_EQ(1, lower_a_string_from_char.GetLength());
353   EXPECT_EQ(lower_a_string, lower_a_string_from_char);
354   EXPECT_NE(nul_string_from_char, lower_a_string_from_char);
355
356   CFX_ByteStringC longer_string("ab");
357   EXPECT_NE(longer_string, lower_a_string_from_char);
358 }
359
360 TEST(fxcrt, ByteStringCGetID) {
361   CFX_ByteStringC null_string;
362   EXPECT_EQ(0u, null_string.GetID());
363   EXPECT_EQ(0u, null_string.GetID(1));
364   EXPECT_EQ(0u, null_string.GetID(-1));
365   EXPECT_EQ(0u, null_string.GetID(-1000000));
366
367   CFX_ByteStringC empty_string("");
368   EXPECT_EQ(0u, empty_string.GetID());
369   EXPECT_EQ(0u, empty_string.GetID(1));
370   EXPECT_EQ(0u, empty_string.GetID(-1));
371   EXPECT_EQ(0u, empty_string.GetID(-1000000));
372
373   CFX_ByteStringC short_string("ab");
374   EXPECT_EQ(FXBSTR_ID('a', 'b', 0, 0), short_string.GetID());
375   EXPECT_EQ(FXBSTR_ID('b', 0, 0, 0), short_string.GetID(1));
376   EXPECT_EQ(0u, short_string.GetID(2));
377   EXPECT_EQ(0u, short_string.GetID(-1));
378   EXPECT_EQ(0u, short_string.GetID(-1000000));
379
380   CFX_ByteStringC longer_string("abcdef");
381   EXPECT_EQ(FXBSTR_ID('a', 'b', 'c', 'd'), longer_string.GetID());
382   EXPECT_EQ(FXBSTR_ID('b', 'c', 'd', 'e'), longer_string.GetID(1));
383   EXPECT_EQ(FXBSTR_ID('c', 'd', 'e', 'f'), longer_string.GetID(2));
384   EXPECT_EQ(FXBSTR_ID('d', 'e', 'f', 0), longer_string.GetID(3));
385   EXPECT_EQ(FXBSTR_ID('e', 'f', 0 , 0), longer_string.GetID(4));
386   EXPECT_EQ(FXBSTR_ID('f', 0 , 0, 0), longer_string.GetID(5));
387   EXPECT_EQ(0u, longer_string.GetID(6));
388   EXPECT_EQ(0u, longer_string.GetID(-1));
389   EXPECT_EQ(0u, longer_string.GetID(-1000000));
390 }
391
392 TEST(fxcrt, ByteStringCMid) {
393   CFX_ByteStringC null_string;
394   EXPECT_EQ(null_string, null_string.Mid(0, 1));
395   EXPECT_EQ(null_string, null_string.Mid(1, 1));
396
397   CFX_ByteStringC empty_string("");
398   EXPECT_EQ(empty_string, empty_string.Mid(0, 1));
399   EXPECT_EQ(empty_string, empty_string.Mid(1, 1));
400
401   CFX_ByteStringC single_character("a");
402   EXPECT_EQ(empty_string, single_character.Mid(0, 0));
403   EXPECT_EQ(single_character, single_character.Mid(0, 1));
404   EXPECT_EQ(empty_string, single_character.Mid(1, 0));
405   EXPECT_EQ(empty_string, single_character.Mid(1, 1));
406
407   CFX_ByteStringC longer_string("abcdef");
408   EXPECT_EQ(longer_string, longer_string.Mid(0, 6));
409   EXPECT_EQ(longer_string, longer_string.Mid(0, 187));
410   EXPECT_EQ(longer_string, longer_string.Mid(-42, 6));
411   EXPECT_EQ(longer_string, longer_string.Mid(-42, 187));
412
413   CFX_ByteStringC leading_substring("ab");
414   EXPECT_EQ(leading_substring, longer_string.Mid(0, 2));
415   EXPECT_EQ(leading_substring, longer_string.Mid(-1, 2));
416
417   CFX_ByteStringC middle_substring("bcde");
418   EXPECT_EQ(middle_substring, longer_string.Mid(1, 4));
419
420   CFX_ByteStringC trailing_substring("ef");
421   EXPECT_EQ(trailing_substring, longer_string.Mid(4, 2));
422   EXPECT_EQ(trailing_substring, longer_string.Mid(4, 3));
423 }
424
425 TEST(fxcrt, ByteStringCGetAt) {
426   CFX_ByteString short_string("a");
427   CFX_ByteString longer_string("abc");
428   CFX_ByteString embedded_nul_string("ab\0c", 4);
429
430   EXPECT_EQ('a', short_string.GetAt(0));
431   EXPECT_EQ('c', longer_string.GetAt(2));
432   EXPECT_EQ('b', embedded_nul_string.GetAt(1));
433   EXPECT_EQ('\0', embedded_nul_string.GetAt(2));
434   EXPECT_EQ('c', embedded_nul_string.GetAt(3));
435 }
436
437 TEST(fxcrt, ByteStringCOperatorSubscript) {
438     // CFX_ByteStringC includes the NUL terminator for non-empty strings.
439     CFX_ByteStringC abc("abc");
440     EXPECT_EQ('a', abc[0]);
441     EXPECT_EQ('b', abc[1]);
442     EXPECT_EQ('c', abc[2]);
443     EXPECT_EQ(0, abc[3]);
444 }
445
446 TEST(fxcrt, ByteStringCOperatorLT) {
447     CFX_ByteStringC empty;
448     CFX_ByteStringC a("a");
449     CFX_ByteStringC abc("abc");
450     CFX_ByteStringC def("def");
451
452     EXPECT_FALSE(empty < empty);
453     EXPECT_FALSE(a < a);
454     EXPECT_FALSE(abc < abc);
455     EXPECT_FALSE(def < def);
456
457     EXPECT_TRUE(empty < a);
458     EXPECT_FALSE(a < empty);
459
460     EXPECT_TRUE(empty < abc);
461     EXPECT_FALSE(abc < empty);
462
463     EXPECT_TRUE(empty < def);
464     EXPECT_FALSE(def < empty);
465
466     EXPECT_TRUE(a < abc);
467     EXPECT_FALSE(abc < a);
468
469     EXPECT_TRUE(a < def);
470     EXPECT_FALSE(def < a);
471
472     EXPECT_TRUE(abc < def);
473     EXPECT_FALSE(def < abc);
474 }
475
476 TEST(fxcrt, ByteStringCOperatorEQ) {
477     CFX_ByteStringC byte_string_c("hello");
478     EXPECT_TRUE(byte_string_c == byte_string_c);
479
480     CFX_ByteStringC byte_string_c_same1("hello");
481     EXPECT_TRUE(byte_string_c == byte_string_c_same1);
482     EXPECT_TRUE(byte_string_c_same1 == byte_string_c);
483
484     CFX_ByteStringC byte_string_c_same2(byte_string_c);
485     EXPECT_TRUE(byte_string_c == byte_string_c_same2);
486     EXPECT_TRUE(byte_string_c_same2 == byte_string_c);
487
488     CFX_ByteStringC byte_string_c1("he");
489     CFX_ByteStringC byte_string_c2("hellp");
490     CFX_ByteStringC byte_string_c3("hellod");
491     EXPECT_FALSE(byte_string_c == byte_string_c1);
492     EXPECT_FALSE(byte_string_c == byte_string_c2);
493     EXPECT_FALSE(byte_string_c == byte_string_c3);
494     EXPECT_FALSE(byte_string_c1 == byte_string_c);
495     EXPECT_FALSE(byte_string_c2 == byte_string_c);
496     EXPECT_FALSE(byte_string_c3 == byte_string_c);
497
498     CFX_ByteString byte_string_same1("hello");
499     EXPECT_TRUE(byte_string_c == byte_string_same1);
500     EXPECT_TRUE(byte_string_same1 == byte_string_c);
501
502     CFX_ByteString byte_string1("he");
503     CFX_ByteString byte_string2("hellp");
504     CFX_ByteString byte_string3("hellod");
505     EXPECT_FALSE(byte_string_c == byte_string1);
506     EXPECT_FALSE(byte_string_c == byte_string2);
507     EXPECT_FALSE(byte_string_c == byte_string3);
508     EXPECT_FALSE(byte_string1 == byte_string_c);
509     EXPECT_FALSE(byte_string2 == byte_string_c);
510     EXPECT_FALSE(byte_string3 == byte_string_c);
511
512     const char* c_string_same1 = "hello";
513     EXPECT_TRUE(byte_string_c == c_string_same1);
514     EXPECT_TRUE(c_string_same1 == byte_string_c);
515
516     const char* c_string1 = "he";
517     const char* c_string2 = "hellp";
518     const char* c_string3 = "hellod";
519     EXPECT_FALSE(byte_string_c == c_string1);
520     EXPECT_FALSE(byte_string_c == c_string2);
521     EXPECT_FALSE(byte_string_c == c_string3);
522
523     EXPECT_FALSE(c_string1 == byte_string_c);
524     EXPECT_FALSE(c_string2 == byte_string_c);
525     EXPECT_FALSE(c_string3 == byte_string_c);
526 }
527
528 TEST(fxcrt, ByteStringCOperatorNE) {
529     CFX_ByteStringC byte_string_c("hello");
530     EXPECT_FALSE(byte_string_c != byte_string_c);
531
532     CFX_ByteStringC byte_string_c_same1("hello");
533     EXPECT_FALSE(byte_string_c != byte_string_c_same1);
534     EXPECT_FALSE(byte_string_c_same1 != byte_string_c);
535
536     CFX_ByteStringC byte_string_c_same2(byte_string_c);
537     EXPECT_FALSE(byte_string_c != byte_string_c_same2);
538     EXPECT_FALSE(byte_string_c_same2 != byte_string_c);
539
540     CFX_ByteStringC byte_string_c1("he");
541     CFX_ByteStringC byte_string_c2("hellp");
542     CFX_ByteStringC byte_string_c3("hellod");
543     EXPECT_TRUE(byte_string_c != byte_string_c1);
544     EXPECT_TRUE(byte_string_c != byte_string_c2);
545     EXPECT_TRUE(byte_string_c != byte_string_c3);
546     EXPECT_TRUE(byte_string_c1 != byte_string_c);
547     EXPECT_TRUE(byte_string_c2 != byte_string_c);
548     EXPECT_TRUE(byte_string_c3 != byte_string_c);
549
550     CFX_ByteString byte_string_same1("hello");
551     EXPECT_FALSE(byte_string_c != byte_string_same1);
552     EXPECT_FALSE(byte_string_same1 != byte_string_c);
553
554     CFX_ByteString byte_string1("he");
555     CFX_ByteString byte_string2("hellp");
556     CFX_ByteString byte_string3("hellod");
557     EXPECT_TRUE(byte_string_c != byte_string1);
558     EXPECT_TRUE(byte_string_c != byte_string2);
559     EXPECT_TRUE(byte_string_c != byte_string3);
560     EXPECT_TRUE(byte_string1 != byte_string_c);
561     EXPECT_TRUE(byte_string2 != byte_string_c);
562     EXPECT_TRUE(byte_string3 != byte_string_c);
563
564     const char* c_string_same1 = "hello";
565     EXPECT_FALSE(byte_string_c != c_string_same1);
566     EXPECT_FALSE(c_string_same1 != byte_string_c);
567
568     const char* c_string1 = "he";
569     const char* c_string2 = "hellp";
570     const char* c_string3 = "hellod";
571     EXPECT_TRUE(byte_string_c != c_string1);
572     EXPECT_TRUE(byte_string_c != c_string2);
573     EXPECT_TRUE(byte_string_c != c_string3);
574
575     EXPECT_TRUE(c_string1 != byte_string_c);
576     EXPECT_TRUE(c_string2 != byte_string_c);
577     EXPECT_TRUE(c_string3 != byte_string_c);
578 }