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

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

Issue 1090303003: Add missing operators for CFX_ByteStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: use size_t 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, ByteStringCNull) { 9 TEST(fxcrt, ByteStringCNull) {
10 CFX_ByteStringC null_string; 10 CFX_ByteStringC null_string;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 CFX_ByteString short_string("a"); 183 CFX_ByteString short_string("a");
184 CFX_ByteString longer_string("abc"); 184 CFX_ByteString longer_string("abc");
185 CFX_ByteString embedded_nul_string("ab\0c", 4); 185 CFX_ByteString embedded_nul_string("ab\0c", 4);
186 186
187 EXPECT_EQ('a', short_string.GetAt(0)); 187 EXPECT_EQ('a', short_string.GetAt(0));
188 EXPECT_EQ('c', longer_string.GetAt(2)); 188 EXPECT_EQ('c', longer_string.GetAt(2));
189 EXPECT_EQ('b', embedded_nul_string.GetAt(1)); 189 EXPECT_EQ('b', embedded_nul_string.GetAt(1));
190 EXPECT_EQ('\0', embedded_nul_string.GetAt(2)); 190 EXPECT_EQ('\0', embedded_nul_string.GetAt(2));
191 EXPECT_EQ('c', embedded_nul_string.GetAt(3)); 191 EXPECT_EQ('c', embedded_nul_string.GetAt(3));
192 } 192 }
193
194 TEST(fxcrt, ByteStringCOperatorSubscript) {
195 // CFX_ByteStringC includes the NUL terminator for non-empty strings.
196 CFX_ByteStringC abc("abc");
197 EXPECT_EQ('a', abc[0]);
198 EXPECT_EQ('b', abc[1]);
199 EXPECT_EQ('c', abc[2]);
200 EXPECT_EQ(0, abc[3]);
201 }
202
203 TEST(fxcrt, ByteStringCOperatorLT) {
204 CFX_ByteStringC empty;
205 CFX_ByteStringC a("a");
206 CFX_ByteStringC abc("abc");
207 CFX_ByteStringC def("def");
208
209 EXPECT_FALSE(empty < empty);
210 EXPECT_FALSE(a < a);
211 EXPECT_FALSE(abc < abc);
212 EXPECT_FALSE(def < def);
213
214 EXPECT_TRUE(empty < a);
215 EXPECT_FALSE(a < empty);
216
217 EXPECT_TRUE(empty < abc);
218 EXPECT_FALSE(abc < empty);
219
220 EXPECT_TRUE(empty < def);
221 EXPECT_FALSE(def < empty);
222
223 EXPECT_TRUE(a < abc);
224 EXPECT_FALSE(abc < a);
225
226 EXPECT_TRUE(a < def);
227 EXPECT_FALSE(def < a);
228
229 EXPECT_TRUE(abc < def);
230 EXPECT_FALSE(def < abc);
231 }
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