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

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

Issue 1095893005: Merge to XFA: Add missing operators for CFX_xxxString combo patch. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 8 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
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 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
9 TEST(fxcrt, ByteStringCNull) { 48 TEST(fxcrt, ByteStringCNull) {
10 CFX_ByteStringC null_string; 49 CFX_ByteStringC null_string;
11 EXPECT_EQ(null_string.GetPtr(), nullptr); 50 EXPECT_EQ(null_string.GetPtr(), nullptr);
12 EXPECT_EQ(null_string.GetLength(), 0); 51 EXPECT_EQ(null_string.GetLength(), 0);
13 EXPECT_TRUE(null_string.IsEmpty()); 52 EXPECT_TRUE(null_string.IsEmpty());
14 53
15 CFX_ByteStringC another_null_string; 54 CFX_ByteStringC another_null_string;
16 EXPECT_EQ(null_string, another_null_string); 55 EXPECT_EQ(null_string, another_null_string);
17 56
18 CFX_ByteStringC copied_null_string(null_string); 57 CFX_ByteStringC copied_null_string(null_string);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 CFX_ByteString short_string("a"); 222 CFX_ByteString short_string("a");
184 CFX_ByteString longer_string("abc"); 223 CFX_ByteString longer_string("abc");
185 CFX_ByteString embedded_nul_string("ab\0c", 4); 224 CFX_ByteString embedded_nul_string("ab\0c", 4);
186 225
187 EXPECT_EQ('a', short_string.GetAt(0)); 226 EXPECT_EQ('a', short_string.GetAt(0));
188 EXPECT_EQ('c', longer_string.GetAt(2)); 227 EXPECT_EQ('c', longer_string.GetAt(2));
189 EXPECT_EQ('b', embedded_nul_string.GetAt(1)); 228 EXPECT_EQ('b', embedded_nul_string.GetAt(1));
190 EXPECT_EQ('\0', embedded_nul_string.GetAt(2)); 229 EXPECT_EQ('\0', embedded_nul_string.GetAt(2));
191 EXPECT_EQ('c', embedded_nul_string.GetAt(3)); 230 EXPECT_EQ('c', embedded_nul_string.GetAt(3));
192 } 231 }
232
233 TEST(fxcrt, ByteStringCOperatorSubscript) {
234 // CFX_ByteStringC includes the NUL terminator for non-empty strings.
235 CFX_ByteStringC abc("abc");
236 EXPECT_EQ('a', abc[0]);
237 EXPECT_EQ('b', abc[1]);
238 EXPECT_EQ('c', abc[2]);
239 EXPECT_EQ(0, abc[3]);
240 }
241
242 TEST(fxcrt, ByteStringCOperatorLT) {
243 CFX_ByteStringC empty;
244 CFX_ByteStringC a("a");
245 CFX_ByteStringC abc("abc");
246 CFX_ByteStringC def("def");
247
248 EXPECT_FALSE(empty < empty);
249 EXPECT_FALSE(a < a);
250 EXPECT_FALSE(abc < abc);
251 EXPECT_FALSE(def < def);
252
253 EXPECT_TRUE(empty < a);
254 EXPECT_FALSE(a < empty);
255
256 EXPECT_TRUE(empty < abc);
257 EXPECT_FALSE(abc < empty);
258
259 EXPECT_TRUE(empty < def);
260 EXPECT_FALSE(def < empty);
261
262 EXPECT_TRUE(a < abc);
263 EXPECT_FALSE(abc < a);
264
265 EXPECT_TRUE(a < def);
266 EXPECT_FALSE(def < a);
267
268 EXPECT_TRUE(abc < def);
269 EXPECT_FALSE(def < abc);
270 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698