Fix some clang warnings with -Wmissing-braces in pdfium.
[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/fx_string_testhelpers.h"
6 #include "../../include/fxcrt/fx_string.h"
7 #include "testing/gtest/include/gtest/gtest.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 = (const FX_CHAR*)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, ByteStringConcatInPlace) {
292     CFX_ByteString fred;
293     fred.ConcatInPlace(4, "FRED");
294     EXPECT_EQ("FRED", fred);
295
296     fred.ConcatInPlace(2, "DY");
297     EXPECT_EQ("FREDDY", fred);
298
299     fred.Delete(3, 3);
300     EXPECT_EQ("FRE", fred);
301
302     fred.ConcatInPlace(1, "D");
303     EXPECT_EQ("FRED", fred);
304
305     CFX_ByteString copy = fred;
306     fred.ConcatInPlace(2, "DY");
307     EXPECT_EQ("FREDDY", fred);
308     EXPECT_EQ("FRED", copy);
309
310     // Test invalid arguments.
311     copy = fred;
312     fred.ConcatInPlace(-6, "freddy");
313     CFX_ByteString not_aliased("xxxxxx");
314     EXPECT_EQ("FREDDY", fred);
315     EXPECT_EQ("xxxxxx", not_aliased);
316 }
317
318 TEST(fxcrt, ByteStringCNotNull) {
319   CFX_ByteStringC string3("abc");
320   CFX_ByteStringC string6("abcdef");
321   CFX_ByteStringC alternate_string3("abcdef", 3);
322   CFX_ByteStringC embedded_nul_string7("abc\0def", 7);
323   CFX_ByteStringC illegal_string7("abcdef", 7);
324
325   EXPECT_EQ(3, string3.GetLength());
326   EXPECT_EQ(6, string6.GetLength());
327   EXPECT_EQ(3, alternate_string3.GetLength());
328   EXPECT_EQ(7, embedded_nul_string7.GetLength());
329   EXPECT_EQ(7, illegal_string7.GetLength());
330
331   EXPECT_NE(string3, string6);
332   EXPECT_EQ(string3, alternate_string3);
333   EXPECT_NE(string3, embedded_nul_string7);
334   EXPECT_NE(string3, illegal_string7);
335   EXPECT_NE(string6, alternate_string3);
336   EXPECT_NE(string6, embedded_nul_string7);
337   EXPECT_NE(string6, illegal_string7);
338   EXPECT_NE(alternate_string3, embedded_nul_string7);
339   EXPECT_NE(alternate_string3, illegal_string7);
340   EXPECT_NE(embedded_nul_string7, illegal_string7);
341
342   CFX_ByteStringC copied_string3(string3);
343   CFX_ByteStringC copied_alternate_string3(alternate_string3);
344   CFX_ByteStringC copied_embedded_nul_string7(embedded_nul_string7);
345
346   EXPECT_EQ(string3, copied_string3);
347   EXPECT_EQ(alternate_string3, copied_alternate_string3);
348   EXPECT_EQ(embedded_nul_string7, copied_embedded_nul_string7);
349
350   CFX_ByteStringC assigned_string3("intially something else");
351   CFX_ByteStringC assigned_alternate_string3("initally something else");
352   CFX_ByteStringC assigned_ptr_string3("initially something else");
353   CFX_ByteStringC assigned_embedded_nul_string7("initially something else");
354
355   assigned_string3 = string3;
356   assigned_alternate_string3 = alternate_string3;
357   assigned_ptr_string3 = "abc";
358   assigned_embedded_nul_string7 = embedded_nul_string7;
359   EXPECT_EQ(string3, assigned_string3);
360   EXPECT_EQ(alternate_string3, assigned_alternate_string3);
361   EXPECT_EQ(alternate_string3, assigned_ptr_string3);
362   EXPECT_EQ(embedded_nul_string7, assigned_embedded_nul_string7);
363 }
364
365 TEST(fxcrt, ByteStringCFromChar) {
366   CFX_ByteStringC null_string;
367   CFX_ByteStringC lower_a_string("a");
368
369   // Must have lvalues that outlive the corresponding ByteStringC.
370   char nul = '\0';
371   char lower_a = 'a';
372   CFX_ByteStringC nul_string_from_char(nul);
373   CFX_ByteStringC lower_a_string_from_char(lower_a);
374
375   // Pointer to nul, not NULL ptr, hence length 1 ...
376   EXPECT_EQ(1, nul_string_from_char.GetLength());
377   EXPECT_NE(null_string, nul_string_from_char);
378
379   EXPECT_EQ(1, lower_a_string_from_char.GetLength());
380   EXPECT_EQ(lower_a_string, lower_a_string_from_char);
381   EXPECT_NE(nul_string_from_char, lower_a_string_from_char);
382
383   CFX_ByteStringC longer_string("ab");
384   EXPECT_NE(longer_string, lower_a_string_from_char);
385 }
386
387 TEST(fxcrt, ByteStringCGetID) {
388   CFX_ByteStringC null_string;
389   EXPECT_EQ(0u, null_string.GetID());
390   EXPECT_EQ(0u, null_string.GetID(1));
391   EXPECT_EQ(0u, null_string.GetID(-1));
392   EXPECT_EQ(0u, null_string.GetID(-1000000));
393
394   CFX_ByteStringC empty_string("");
395   EXPECT_EQ(0u, empty_string.GetID());
396   EXPECT_EQ(0u, empty_string.GetID(1));
397   EXPECT_EQ(0u, empty_string.GetID(-1));
398   EXPECT_EQ(0u, empty_string.GetID(-1000000));
399
400   CFX_ByteStringC short_string("ab");
401   EXPECT_EQ(FXBSTR_ID('a', 'b', 0, 0), short_string.GetID());
402   EXPECT_EQ(FXBSTR_ID('b', 0, 0, 0), short_string.GetID(1));
403   EXPECT_EQ(0u, short_string.GetID(2));
404   EXPECT_EQ(0u, short_string.GetID(-1));
405   EXPECT_EQ(0u, short_string.GetID(-1000000));
406
407   CFX_ByteStringC longer_string("abcdef");
408   EXPECT_EQ(FXBSTR_ID('a', 'b', 'c', 'd'), longer_string.GetID());
409   EXPECT_EQ(FXBSTR_ID('b', 'c', 'd', 'e'), longer_string.GetID(1));
410   EXPECT_EQ(FXBSTR_ID('c', 'd', 'e', 'f'), longer_string.GetID(2));
411   EXPECT_EQ(FXBSTR_ID('d', 'e', 'f', 0), longer_string.GetID(3));
412   EXPECT_EQ(FXBSTR_ID('e', 'f', 0 , 0), longer_string.GetID(4));
413   EXPECT_EQ(FXBSTR_ID('f', 0 , 0, 0), longer_string.GetID(5));
414   EXPECT_EQ(0u, longer_string.GetID(6));
415   EXPECT_EQ(0u, longer_string.GetID(-1));
416   EXPECT_EQ(0u, longer_string.GetID(-1000000));
417 }
418
419 TEST(fxcrt, ByteStringCMid) {
420   CFX_ByteStringC null_string;
421   EXPECT_EQ(null_string, null_string.Mid(0, 1));
422   EXPECT_EQ(null_string, null_string.Mid(1, 1));
423
424   CFX_ByteStringC empty_string("");
425   EXPECT_EQ(empty_string, empty_string.Mid(0, 1));
426   EXPECT_EQ(empty_string, empty_string.Mid(1, 1));
427
428   CFX_ByteStringC single_character("a");
429   EXPECT_EQ(empty_string, single_character.Mid(0, 0));
430   EXPECT_EQ(single_character, single_character.Mid(0, 1));
431   EXPECT_EQ(empty_string, single_character.Mid(1, 0));
432   EXPECT_EQ(empty_string, single_character.Mid(1, 1));
433
434   CFX_ByteStringC longer_string("abcdef");
435   EXPECT_EQ(longer_string, longer_string.Mid(0, 6));
436   EXPECT_EQ(longer_string, longer_string.Mid(0, 187));
437   EXPECT_EQ(longer_string, longer_string.Mid(-42, 6));
438   EXPECT_EQ(longer_string, longer_string.Mid(-42, 187));
439
440   CFX_ByteStringC leading_substring("ab");
441   EXPECT_EQ(leading_substring, longer_string.Mid(0, 2));
442   EXPECT_EQ(leading_substring, longer_string.Mid(-1, 2));
443
444   CFX_ByteStringC middle_substring("bcde");
445   EXPECT_EQ(middle_substring, longer_string.Mid(1, 4));
446
447   CFX_ByteStringC trailing_substring("ef");
448   EXPECT_EQ(trailing_substring, longer_string.Mid(4, 2));
449   EXPECT_EQ(trailing_substring, longer_string.Mid(4, 3));
450 }
451
452 TEST(fxcrt, ByteStringCGetAt) {
453   CFX_ByteString short_string("a");
454   CFX_ByteString longer_string("abc");
455   CFX_ByteString embedded_nul_string("ab\0c", 4);
456
457   EXPECT_EQ('a', short_string.GetAt(0));
458   EXPECT_EQ('c', longer_string.GetAt(2));
459   EXPECT_EQ('b', embedded_nul_string.GetAt(1));
460   EXPECT_EQ('\0', embedded_nul_string.GetAt(2));
461   EXPECT_EQ('c', embedded_nul_string.GetAt(3));
462 }
463
464 TEST(fxcrt, ByteStringCOperatorSubscript) {
465     // CFX_ByteStringC includes the NUL terminator for non-empty strings.
466     CFX_ByteStringC abc("abc");
467     EXPECT_EQ('a', abc[0]);
468     EXPECT_EQ('b', abc[1]);
469     EXPECT_EQ('c', abc[2]);
470     EXPECT_EQ(0, abc[3]);
471 }
472
473 TEST(fxcrt, ByteStringCOperatorLT) {
474     CFX_ByteStringC empty;
475     CFX_ByteStringC a("a");
476     CFX_ByteStringC abc("abc");
477     CFX_ByteStringC def("def");
478
479     EXPECT_FALSE(empty < empty);
480     EXPECT_FALSE(a < a);
481     EXPECT_FALSE(abc < abc);
482     EXPECT_FALSE(def < def);
483
484     EXPECT_TRUE(empty < a);
485     EXPECT_FALSE(a < empty);
486
487     EXPECT_TRUE(empty < abc);
488     EXPECT_FALSE(abc < empty);
489
490     EXPECT_TRUE(empty < def);
491     EXPECT_FALSE(def < empty);
492
493     EXPECT_TRUE(a < abc);
494     EXPECT_FALSE(abc < a);
495
496     EXPECT_TRUE(a < def);
497     EXPECT_FALSE(def < a);
498
499     EXPECT_TRUE(abc < def);
500     EXPECT_FALSE(def < abc);
501 }
502
503 TEST(fxcrt, ByteStringCOperatorEQ) {
504     CFX_ByteStringC byte_string_c("hello");
505     EXPECT_TRUE(byte_string_c == byte_string_c);
506
507     CFX_ByteStringC byte_string_c_same1("hello");
508     EXPECT_TRUE(byte_string_c == byte_string_c_same1);
509     EXPECT_TRUE(byte_string_c_same1 == byte_string_c);
510
511     CFX_ByteStringC byte_string_c_same2(byte_string_c);
512     EXPECT_TRUE(byte_string_c == byte_string_c_same2);
513     EXPECT_TRUE(byte_string_c_same2 == byte_string_c);
514
515     CFX_ByteStringC byte_string_c1("he");
516     CFX_ByteStringC byte_string_c2("hellp");
517     CFX_ByteStringC byte_string_c3("hellod");
518     EXPECT_FALSE(byte_string_c == byte_string_c1);
519     EXPECT_FALSE(byte_string_c == byte_string_c2);
520     EXPECT_FALSE(byte_string_c == byte_string_c3);
521     EXPECT_FALSE(byte_string_c1 == byte_string_c);
522     EXPECT_FALSE(byte_string_c2 == byte_string_c);
523     EXPECT_FALSE(byte_string_c3 == byte_string_c);
524
525     CFX_ByteString byte_string_same1("hello");
526     EXPECT_TRUE(byte_string_c == byte_string_same1);
527     EXPECT_TRUE(byte_string_same1 == byte_string_c);
528
529     CFX_ByteString byte_string1("he");
530     CFX_ByteString byte_string2("hellp");
531     CFX_ByteString byte_string3("hellod");
532     EXPECT_FALSE(byte_string_c == byte_string1);
533     EXPECT_FALSE(byte_string_c == byte_string2);
534     EXPECT_FALSE(byte_string_c == byte_string3);
535     EXPECT_FALSE(byte_string1 == byte_string_c);
536     EXPECT_FALSE(byte_string2 == byte_string_c);
537     EXPECT_FALSE(byte_string3 == byte_string_c);
538
539     const char* c_string_same1 = "hello";
540     EXPECT_TRUE(byte_string_c == c_string_same1);
541     EXPECT_TRUE(c_string_same1 == byte_string_c);
542
543     const char* c_string1 = "he";
544     const char* c_string2 = "hellp";
545     const char* c_string3 = "hellod";
546     EXPECT_FALSE(byte_string_c == c_string1);
547     EXPECT_FALSE(byte_string_c == c_string2);
548     EXPECT_FALSE(byte_string_c == c_string3);
549
550     EXPECT_FALSE(c_string1 == byte_string_c);
551     EXPECT_FALSE(c_string2 == byte_string_c);
552     EXPECT_FALSE(c_string3 == byte_string_c);
553 }
554
555 TEST(fxcrt, ByteStringCOperatorNE) {
556     CFX_ByteStringC byte_string_c("hello");
557     EXPECT_FALSE(byte_string_c != byte_string_c);
558
559     CFX_ByteStringC byte_string_c_same1("hello");
560     EXPECT_FALSE(byte_string_c != byte_string_c_same1);
561     EXPECT_FALSE(byte_string_c_same1 != byte_string_c);
562
563     CFX_ByteStringC byte_string_c_same2(byte_string_c);
564     EXPECT_FALSE(byte_string_c != byte_string_c_same2);
565     EXPECT_FALSE(byte_string_c_same2 != byte_string_c);
566
567     CFX_ByteStringC byte_string_c1("he");
568     CFX_ByteStringC byte_string_c2("hellp");
569     CFX_ByteStringC byte_string_c3("hellod");
570     EXPECT_TRUE(byte_string_c != byte_string_c1);
571     EXPECT_TRUE(byte_string_c != byte_string_c2);
572     EXPECT_TRUE(byte_string_c != byte_string_c3);
573     EXPECT_TRUE(byte_string_c1 != byte_string_c);
574     EXPECT_TRUE(byte_string_c2 != byte_string_c);
575     EXPECT_TRUE(byte_string_c3 != byte_string_c);
576
577     CFX_ByteString byte_string_same1("hello");
578     EXPECT_FALSE(byte_string_c != byte_string_same1);
579     EXPECT_FALSE(byte_string_same1 != byte_string_c);
580
581     CFX_ByteString byte_string1("he");
582     CFX_ByteString byte_string2("hellp");
583     CFX_ByteString byte_string3("hellod");
584     EXPECT_TRUE(byte_string_c != byte_string1);
585     EXPECT_TRUE(byte_string_c != byte_string2);
586     EXPECT_TRUE(byte_string_c != byte_string3);
587     EXPECT_TRUE(byte_string1 != byte_string_c);
588     EXPECT_TRUE(byte_string2 != byte_string_c);
589     EXPECT_TRUE(byte_string3 != byte_string_c);
590
591     const char* c_string_same1 = "hello";
592     EXPECT_FALSE(byte_string_c != c_string_same1);
593     EXPECT_FALSE(c_string_same1 != byte_string_c);
594
595     const char* c_string1 = "he";
596     const char* c_string2 = "hellp";
597     const char* c_string3 = "hellod";
598     EXPECT_TRUE(byte_string_c != c_string1);
599     EXPECT_TRUE(byte_string_c != c_string2);
600     EXPECT_TRUE(byte_string_c != c_string3);
601
602     EXPECT_TRUE(c_string1 != byte_string_c);
603     EXPECT_TRUE(c_string2 != byte_string_c);
604     EXPECT_TRUE(c_string3 != byte_string_c);
605 }