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 "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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 assigned_nullptr_string = (FX_LPCSTR)nullptr; | 281 assigned_nullptr_string = (FX_LPCSTR)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, ByteStringConcatInPlace) { |
| 292 CFX_ByteString fred; |
| 293 fred.ConcatInPlace(4, "FRED"); |
| 294 EXPECT_EQ("FRED", fred); |
| 295 |
| 296 fred.ConcatInPlace(2, "DY"); |
| 297 EXPECT_EQ("FREDDY", fred); |
| 298 |
| 299 fred.Delete(3, 3); |
| 300 EXPECT_EQ("FRE", fred); |
| 301 |
| 302 fred.ConcatInPlace(1, "D"); |
| 303 EXPECT_EQ("FRED", fred); |
| 304 |
| 305 CFX_ByteString copy = fred; |
| 306 fred.ConcatInPlace(2, "DY"); |
| 307 EXPECT_EQ("FREDDY", fred); |
| 308 EXPECT_EQ("FRED", copy); |
| 309 |
| 310 // Test invalid arguments. |
| 311 copy = fred; |
| 312 fred.ConcatInPlace(-6, "freddy"); |
| 313 CFX_ByteString not_aliased("xxxxxx"); |
| 314 EXPECT_EQ("FREDDY", fred); |
| 315 EXPECT_EQ("xxxxxx", not_aliased); |
| 316 } |
| 317 |
291 TEST(fxcrt, ByteStringCNotNull) { | 318 TEST(fxcrt, ByteStringCNotNull) { |
292 CFX_ByteStringC string3("abc"); | 319 CFX_ByteStringC string3("abc"); |
293 CFX_ByteStringC string6("abcdef"); | 320 CFX_ByteStringC string6("abcdef"); |
294 CFX_ByteStringC alternate_string3("abcdef", 3); | 321 CFX_ByteStringC alternate_string3("abcdef", 3); |
295 CFX_ByteStringC embedded_nul_string7("abc\0def", 7); | 322 CFX_ByteStringC embedded_nul_string7("abc\0def", 7); |
296 CFX_ByteStringC illegal_string7("abcdef", 7); | 323 CFX_ByteStringC illegal_string7("abcdef", 7); |
297 | 324 |
298 EXPECT_EQ(3, string3.GetLength()); | 325 EXPECT_EQ(3, string3.GetLength()); |
299 EXPECT_EQ(6, string6.GetLength()); | 326 EXPECT_EQ(6, string6.GetLength()); |
300 EXPECT_EQ(3, alternate_string3.GetLength()); | 327 EXPECT_EQ(3, alternate_string3.GetLength()); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 const char* c_string2 = "hellp"; | 596 const char* c_string2 = "hellp"; |
570 const char* c_string3 = "hellod"; | 597 const char* c_string3 = "hellod"; |
571 EXPECT_TRUE(byte_string_c != c_string1); | 598 EXPECT_TRUE(byte_string_c != c_string1); |
572 EXPECT_TRUE(byte_string_c != c_string2); | 599 EXPECT_TRUE(byte_string_c != c_string2); |
573 EXPECT_TRUE(byte_string_c != c_string3); | 600 EXPECT_TRUE(byte_string_c != c_string3); |
574 | 601 |
575 EXPECT_TRUE(c_string1 != byte_string_c); | 602 EXPECT_TRUE(c_string1 != byte_string_c); |
576 EXPECT_TRUE(c_string2 != byte_string_c); | 603 EXPECT_TRUE(c_string2 != byte_string_c); |
577 EXPECT_TRUE(c_string3 != byte_string_c); | 604 EXPECT_TRUE(c_string3 != byte_string_c); |
578 } | 605 } |
OLD | NEW |