Fix some clang warnings with -Wmissing-braces in pdfium.
[pdfium.git] / core / src / fxcrt / fx_basic_bstring_unittest.cpp
index 1f80207..f865602 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "testing/gtest/include/gtest/gtest.h"
 #include "../../../testing/fx_string_testhelpers.h"
-#include "../../include/fxcrt/fx_basic.h"
+#include "../../include/fxcrt/fx_string.h"
+#include "testing/gtest/include/gtest/gtest.h"
 
 TEST(fxcrt, ByteStringOperatorSubscript) {
     // CFX_ByteString includes the NUL terminator for non-empty strings.
@@ -278,7 +278,7 @@ TEST(fxcrt, ByteStringCNull) {
   EXPECT_EQ(null_string, assigned_null_string);
 
   CFX_ByteStringC assigned_nullptr_string("initially not NULL");
-  assigned_nullptr_string = (FX_LPCSTR)nullptr;
+  assigned_nullptr_string = (const FX_CHAR*)nullptr;
   EXPECT_EQ(assigned_nullptr_string.GetPtr(), nullptr);
   EXPECT_EQ(assigned_nullptr_string.GetLength(), 0);
   EXPECT_TRUE(assigned_nullptr_string.IsEmpty());
@@ -288,6 +288,33 @@ TEST(fxcrt, ByteStringCNull) {
   EXPECT_NE(null_string, non_null_string);
 }
 
+TEST(fxcrt, ByteStringConcatInPlace) {
+    CFX_ByteString fred;
+    fred.ConcatInPlace(4, "FRED");
+    EXPECT_EQ("FRED", fred);
+
+    fred.ConcatInPlace(2, "DY");
+    EXPECT_EQ("FREDDY", fred);
+
+    fred.Delete(3, 3);
+    EXPECT_EQ("FRE", fred);
+
+    fred.ConcatInPlace(1, "D");
+    EXPECT_EQ("FRED", fred);
+
+    CFX_ByteString copy = fred;
+    fred.ConcatInPlace(2, "DY");
+    EXPECT_EQ("FREDDY", fred);
+    EXPECT_EQ("FRED", copy);
+
+    // Test invalid arguments.
+    copy = fred;
+    fred.ConcatInPlace(-6, "freddy");
+    CFX_ByteString not_aliased("xxxxxx");
+    EXPECT_EQ("FREDDY", fred);
+    EXPECT_EQ("xxxxxx", not_aliased);
+}
+
 TEST(fxcrt, ByteStringCNotNull) {
   CFX_ByteStringC string3("abc");
   CFX_ByteStringC string6("abcdef");