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

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

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: s/NULL/nullptr/ Created 4 years, 6 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
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 "core/fxcrt/include/fx_string.h" 5 #include "core/fxcrt/include/fx_string.h"
6 #include "testing/fx_string_testhelpers.h" 6 #include "testing/fx_string_testhelpers.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 CFX_ByteStringC another_null_string; 258 CFX_ByteStringC another_null_string;
259 EXPECT_EQ(null_string, another_null_string); 259 EXPECT_EQ(null_string, another_null_string);
260 260
261 CFX_ByteStringC copied_null_string(null_string); 261 CFX_ByteStringC copied_null_string(null_string);
262 EXPECT_EQ(copied_null_string.raw_str(), nullptr); 262 EXPECT_EQ(copied_null_string.raw_str(), nullptr);
263 EXPECT_EQ(copied_null_string.GetLength(), 0); 263 EXPECT_EQ(copied_null_string.GetLength(), 0);
264 EXPECT_TRUE(copied_null_string.IsEmpty()); 264 EXPECT_TRUE(copied_null_string.IsEmpty());
265 EXPECT_EQ(null_string, copied_null_string); 265 EXPECT_EQ(null_string, copied_null_string);
266 266
267 CFX_ByteStringC empty_string(""); // Pointer to NUL, not NULL pointer. 267 CFX_ByteStringC empty_string(""); // Pointer to NUL, not nullptr pointer.
Tom Sepez 2016/06/02 20:09:49 ditto for comment.
Lei Zhang 2016/06/07 07:33:23 Done.
268 EXPECT_NE(empty_string.raw_str(), nullptr); 268 EXPECT_NE(empty_string.raw_str(), nullptr);
269 EXPECT_EQ(empty_string.GetLength(), 0); 269 EXPECT_EQ(empty_string.GetLength(), 0);
270 EXPECT_TRUE(empty_string.IsEmpty()); 270 EXPECT_TRUE(empty_string.IsEmpty());
271 EXPECT_EQ(null_string, empty_string); 271 EXPECT_EQ(null_string, empty_string);
272 272
273 CFX_ByteStringC assigned_null_string("initially not NULL"); 273 CFX_ByteStringC assigned_null_string("initially not nullptr");
274 assigned_null_string = null_string; 274 assigned_null_string = null_string;
275 EXPECT_EQ(assigned_null_string.raw_str(), nullptr); 275 EXPECT_EQ(assigned_null_string.raw_str(), nullptr);
276 EXPECT_EQ(assigned_null_string.GetLength(), 0); 276 EXPECT_EQ(assigned_null_string.GetLength(), 0);
277 EXPECT_TRUE(assigned_null_string.IsEmpty()); 277 EXPECT_TRUE(assigned_null_string.IsEmpty());
278 EXPECT_EQ(null_string, assigned_null_string); 278 EXPECT_EQ(null_string, assigned_null_string);
279 279
280 CFX_ByteStringC assigned_nullptr_string("initially not NULL"); 280 CFX_ByteStringC assigned_nullptr_string("initially not nullptr");
281 assigned_nullptr_string = (const FX_CHAR*)nullptr; 281 assigned_nullptr_string = (const FX_CHAR*)nullptr;
282 EXPECT_EQ(assigned_nullptr_string.raw_str(), nullptr); 282 EXPECT_EQ(assigned_nullptr_string.raw_str(), nullptr);
283 EXPECT_EQ(assigned_nullptr_string.GetLength(), 0); 283 EXPECT_EQ(assigned_nullptr_string.GetLength(), 0);
284 EXPECT_TRUE(assigned_nullptr_string.IsEmpty()); 284 EXPECT_TRUE(assigned_nullptr_string.IsEmpty());
285 EXPECT_EQ(null_string, assigned_nullptr_string); 285 EXPECT_EQ(null_string, assigned_nullptr_string);
286 286
287 CFX_ByteStringC non_null_string("a"); 287 CFX_ByteStringC non_null_string("a");
288 EXPECT_NE(null_string, non_null_string); 288 EXPECT_NE(null_string, non_null_string);
289 } 289 }
290 290
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 TEST(fxcrt, ByteStringCFromChar) { 751 TEST(fxcrt, ByteStringCFromChar) {
752 CFX_ByteStringC null_string; 752 CFX_ByteStringC null_string;
753 CFX_ByteStringC lower_a_string("a"); 753 CFX_ByteStringC lower_a_string("a");
754 754
755 // Must have lvalues that outlive the corresponding ByteStringC. 755 // Must have lvalues that outlive the corresponding ByteStringC.
756 char nul = '\0'; 756 char nul = '\0';
757 char lower_a = 'a'; 757 char lower_a = 'a';
758 CFX_ByteStringC nul_string_from_char(nul); 758 CFX_ByteStringC nul_string_from_char(nul);
759 CFX_ByteStringC lower_a_string_from_char(lower_a); 759 CFX_ByteStringC lower_a_string_from_char(lower_a);
760 760
761 // Pointer to nul, not NULL ptr, hence length 1 ... 761 // Pointer to nul, not nullptr ptr, hence length 1 ...
Tom Sepez 2016/06/02 20:09:49 ditto
Lei Zhang 2016/06/07 07:33:23 Done.
762 EXPECT_EQ(1, nul_string_from_char.GetLength()); 762 EXPECT_EQ(1, nul_string_from_char.GetLength());
763 EXPECT_NE(null_string, nul_string_from_char); 763 EXPECT_NE(null_string, nul_string_from_char);
764 764
765 EXPECT_EQ(1, lower_a_string_from_char.GetLength()); 765 EXPECT_EQ(1, lower_a_string_from_char.GetLength());
766 EXPECT_EQ(lower_a_string, lower_a_string_from_char); 766 EXPECT_EQ(lower_a_string, lower_a_string_from_char);
767 EXPECT_NE(nul_string_from_char, lower_a_string_from_char); 767 EXPECT_NE(nul_string_from_char, lower_a_string_from_char);
768 768
769 CFX_ByteStringC longer_string("ab"); 769 CFX_ByteStringC longer_string("ab");
770 EXPECT_NE(longer_string, lower_a_string_from_char); 770 EXPECT_NE(longer_string, lower_a_string_from_char);
771 } 771 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1091 }
1092 } 1092 }
1093 1093
1094 TEST(fxcrt, EmptyByteString) { 1094 TEST(fxcrt, EmptyByteString) {
1095 CFX_ByteString empty_str; 1095 CFX_ByteString empty_str;
1096 EXPECT_TRUE(empty_str.IsEmpty()); 1096 EXPECT_TRUE(empty_str.IsEmpty());
1097 EXPECT_EQ(0, empty_str.GetLength()); 1097 EXPECT_EQ(0, empty_str.GetLength());
1098 const FX_CHAR* cstr = empty_str.c_str(); 1098 const FX_CHAR* cstr = empty_str.c_str();
1099 EXPECT_EQ(0, FXSYS_strlen(cstr)); 1099 EXPECT_EQ(0, FXSYS_strlen(cstr));
1100 } 1100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698