| OLD | NEW |
| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 assigned_nullptr_string = (const FX_CHAR*)nullptr; | 281 assigned_nullptr_string = (const FX_CHAR*)nullptr; |
| 282 EXPECT_EQ(assigned_nullptr_string.GetPtr(), nullptr); | 282 EXPECT_EQ(assigned_nullptr_string.GetPtr(), 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 |
| 291 TEST(fxcrt, ByteStringConcat) { | 291 TEST(fxcrt, ByteStringConcatInPlace) { |
| 292 CFX_ByteString fred; | 292 CFX_ByteString fred; |
| 293 fred.Concat("FRED", 4); | 293 fred.ConcatInPlace(4, "FRED"); |
| 294 EXPECT_EQ("FRED", fred); | 294 EXPECT_EQ("FRED", fred); |
| 295 | 295 |
| 296 fred.Concat("DY", 2); | 296 fred.ConcatInPlace(2, "DY"); |
| 297 EXPECT_EQ("FREDDY", fred); | 297 EXPECT_EQ("FREDDY", fred); |
| 298 | 298 |
| 299 fred.Delete(3, 3); | 299 fred.Delete(3, 3); |
| 300 EXPECT_EQ("FRE", fred); | 300 EXPECT_EQ("FRE", fred); |
| 301 | 301 |
| 302 fred.Concat("D", 1); | 302 fred.ConcatInPlace(1, "D"); |
| 303 EXPECT_EQ("FRED", fred); | 303 EXPECT_EQ("FRED", fred); |
| 304 | 304 |
| 305 CFX_ByteString copy = fred; | 305 CFX_ByteString copy = fred; |
| 306 fred.Concat("DY", 2); | 306 fred.ConcatInPlace(2, "DY"); |
| 307 EXPECT_EQ("FREDDY", fred); | 307 EXPECT_EQ("FREDDY", fred); |
| 308 EXPECT_EQ("FRED", copy); | 308 EXPECT_EQ("FRED", copy); |
| 309 | 309 |
| 310 // Test invalid arguments. | 310 // Test invalid arguments. |
| 311 copy = fred; | 311 copy = fred; |
| 312 fred.Concat("freddy", -6); | 312 fred.ConcatInPlace(-6, "freddy"); |
| 313 CFX_ByteString not_aliased("xxxxxx"); | 313 CFX_ByteString not_aliased("xxxxxx"); |
| 314 EXPECT_EQ("FREDDY", fred); | 314 EXPECT_EQ("FREDDY", fred); |
| 315 EXPECT_EQ("xxxxxx", not_aliased); | 315 EXPECT_EQ("xxxxxx", not_aliased); |
| 316 } | 316 } |
| 317 | 317 |
| 318 TEST(fxcrt, ByteStringCNotNull) { | 318 TEST(fxcrt, ByteStringCNotNull) { |
| 319 CFX_ByteStringC string3("abc"); | 319 CFX_ByteStringC string3("abc"); |
| 320 CFX_ByteStringC string6("abcdef"); | 320 CFX_ByteStringC string6("abcdef"); |
| 321 CFX_ByteStringC alternate_string3("abcdef", 3); | 321 CFX_ByteStringC alternate_string3("abcdef", 3); |
| 322 CFX_ByteStringC embedded_nul_string7("abc\0def", 7); | 322 CFX_ByteStringC embedded_nul_string7("abc\0def", 7); |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } | 680 } |
| 681 } | 681 } |
| 682 | 682 |
| 683 TEST(fxcrt, EmptyByteString) { | 683 TEST(fxcrt, EmptyByteString) { |
| 684 CFX_ByteString empty_str; | 684 CFX_ByteString empty_str; |
| 685 EXPECT_TRUE(empty_str.IsEmpty()); | 685 EXPECT_TRUE(empty_str.IsEmpty()); |
| 686 EXPECT_EQ(0, empty_str.GetLength()); | 686 EXPECT_EQ(0, empty_str.GetLength()); |
| 687 const FX_CHAR* cstr = empty_str.c_str(); | 687 const FX_CHAR* cstr = empty_str.c_str(); |
| 688 EXPECT_EQ(0, FXSYS_strlen(cstr)); | 688 EXPECT_EQ(0, FXSYS_strlen(cstr)); |
| 689 } | 689 } |
| OLD | NEW |