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

Side by Side Diff: core/src/fxcrt/fx_basic_bstring_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
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring_unittest.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) { 9 TEST(fxcrt, ByteStringOperatorSubscript) {
10 // CFX_ByteString includes the NUL terminator for non-empty strings. 10 // CFX_ByteString 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, ByteStringOperatorEQ) {
49 CFX_ByteString byteString("hello");
Lei Zhang 2015/05/01 21:50:38 Can we name these byte_string and so on?
Tom Sepez 2015/05/01 22:58:41 Done.
50 ASSERT_TRUE(byteString == byteString);
51
52 CFX_ByteString byteStringSame1("hello");
53 ASSERT_TRUE(byteString == byteStringSame1);
54 ASSERT_TRUE(byteStringSame1 == byteString);
55
56 CFX_ByteString byteStringSame2(byteString);
57 ASSERT_TRUE(byteString == byteStringSame2);
58 ASSERT_TRUE(byteStringSame2 == byteString);
59
60 CFX_ByteString byteString1("he");
61 CFX_ByteString byteString2("hellp");
62 CFX_ByteString byteString3("hellod");
63 ASSERT_FALSE(byteString == byteString1);
64 ASSERT_FALSE(byteString == byteString2);
65 ASSERT_FALSE(byteString == byteString3);
66 ASSERT_FALSE(byteString1 == byteString);
67 ASSERT_FALSE(byteString2 == byteString);
68 ASSERT_FALSE(byteString3 == byteString);
69
70 CFX_ByteStringC byteStringCSame1("hello");
71 ASSERT_TRUE(byteString == byteStringCSame1);
72 ASSERT_TRUE(byteStringCSame1 == byteString);
73
74 CFX_ByteStringC byteStringC1("he");
75 CFX_ByteStringC byteStringC2("hellp");
76 CFX_ByteStringC byteStringC3("hellod");
77 ASSERT_FALSE(byteString == byteStringC1);
78 ASSERT_FALSE(byteString == byteStringC2);
79 ASSERT_FALSE(byteString == byteStringC3);
80 ASSERT_FALSE(byteStringC1 == byteString);
81 ASSERT_FALSE(byteStringC2 == byteString);
82 ASSERT_FALSE(byteStringC3 == byteString);
83
84 const char* cStringSame1 = "hello";
85 ASSERT_TRUE(byteString == cStringSame1);
86 #if 0
87 // TODO(tsepez): See, you don't want implicit c_str() casting.
88 // This degrades to a pointer comparision, which flunks.
89 ASSERT_TRUE(cStringSame1 == byteString);
90 #endif
91
92 const char* cString1 = "he";
93 const char* cString2 = "hellp";
94 const char* cString3 = "hellod";
95 ASSERT_FALSE(byteString == cString1);
96 ASSERT_FALSE(byteString == cString2);
97 ASSERT_FALSE(byteString == cString3);
98 ASSERT_FALSE(cString1 == byteString);
99 ASSERT_FALSE(cString2 == byteString);
100 ASSERT_FALSE(cString3 == byteString);
101 }
102
103 TEST(fxcrt, ByteStringOperatorNE) {
104 CFX_ByteString byteString("hello");
105 ASSERT_FALSE(byteString != byteString);
106
107 CFX_ByteString byteStringSame1("hello");
108 ASSERT_FALSE(byteString != byteStringSame1);
109 ASSERT_FALSE(byteStringSame1 != byteString);
110
111 CFX_ByteString byteStringSame2(byteString);
112 ASSERT_FALSE(byteString != byteStringSame2);
113 ASSERT_FALSE(byteStringSame2 != byteString);
114
115 CFX_ByteString byteString1("he");
116 CFX_ByteString byteString2("hellp");
117 CFX_ByteString byteString3("hellod");
118 ASSERT_TRUE(byteString != byteString1);
119 ASSERT_TRUE(byteString != byteString2);
120 ASSERT_TRUE(byteString != byteString3);
121 ASSERT_TRUE(byteString1 != byteString);
122 ASSERT_TRUE(byteString2 != byteString);
123 ASSERT_TRUE(byteString3 != byteString);
124
125 CFX_ByteStringC byteStringCSame1("hello");
126 ASSERT_FALSE(byteString != byteStringCSame1);
127 ASSERT_FALSE(byteStringCSame1 != byteString);
128
129 CFX_ByteStringC byteStringC1("he");
130 CFX_ByteStringC byteStringC2("hellp");
131 CFX_ByteStringC byteStringC3("hellod");
132 ASSERT_TRUE(byteString != byteStringC1);
133 ASSERT_TRUE(byteString != byteStringC2);
134 ASSERT_TRUE(byteString != byteStringC3);
135 ASSERT_TRUE(byteStringC1 != byteString);
136 ASSERT_TRUE(byteStringC2 != byteString);
137 ASSERT_TRUE(byteStringC3 != byteString);
138
139 const char* cStringSame1 = "hello";
140 ASSERT_FALSE(byteString != cStringSame1);
141 #if 0
142 // See above TODO.
143 ASSERT_FALSE(cStringSame1 != byteString);
144 #endif
145 const char* cString1 = "he";
146 const char* cString2 = "hellp";
147 const char* cString3 = "hellod";
148 ASSERT_TRUE(byteString != cString1);
149 ASSERT_TRUE(byteString != cString2);
150 ASSERT_TRUE(byteString != cString3);
151 ASSERT_TRUE(cString1 != byteString);
152 ASSERT_TRUE(cString2 != byteString);
153 ASSERT_TRUE(cString3 != byteString);
154 }
155
48 TEST(fxcrt, ByteStringCNull) { 156 TEST(fxcrt, ByteStringCNull) {
49 CFX_ByteStringC null_string; 157 CFX_ByteStringC null_string;
50 EXPECT_EQ(null_string.GetPtr(), nullptr); 158 EXPECT_EQ(null_string.GetPtr(), nullptr);
51 EXPECT_EQ(null_string.GetLength(), 0); 159 EXPECT_EQ(null_string.GetLength(), 0);
52 EXPECT_TRUE(null_string.IsEmpty()); 160 EXPECT_TRUE(null_string.IsEmpty());
53 161
54 CFX_ByteStringC another_null_string; 162 CFX_ByteStringC another_null_string;
55 EXPECT_EQ(null_string, another_null_string); 163 EXPECT_EQ(null_string, another_null_string);
56 164
57 CFX_ByteStringC copied_null_string(null_string); 165 CFX_ByteStringC copied_null_string(null_string);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 369
262 EXPECT_TRUE(a < abc); 370 EXPECT_TRUE(a < abc);
263 EXPECT_FALSE(abc < a); 371 EXPECT_FALSE(abc < a);
264 372
265 EXPECT_TRUE(a < def); 373 EXPECT_TRUE(a < def);
266 EXPECT_FALSE(def < a); 374 EXPECT_FALSE(def < a);
267 375
268 EXPECT_TRUE(abc < def); 376 EXPECT_TRUE(abc < def);
269 EXPECT_FALSE(def < abc); 377 EXPECT_FALSE(def < abc);
270 } 378 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698