Whitespace changes in fx_system_unittest.cpp to match XFA
[pdfium.git] / core / src / fxcrt / fx_basic_bstring_unittest.cpp
index 1f80207..3779397 100644 (file)
 // 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.
-    CFX_ByteString abc("abc");
-    EXPECT_EQ('a', abc[0]);
-    EXPECT_EQ('b', abc[1]);
-    EXPECT_EQ('c', abc[2]);
-    EXPECT_EQ(0, abc[3]);
+  // CFX_ByteString includes the NUL terminator for non-empty strings.
+  CFX_ByteString abc("abc");
+  EXPECT_EQ('a', abc[0]);
+  EXPECT_EQ('b', abc[1]);
+  EXPECT_EQ('c', abc[2]);
+  EXPECT_EQ(0, abc[3]);
 }
 
 TEST(fxcrt, ByteStringOperatorLT) {
-    CFX_ByteString empty;
-    CFX_ByteString a("a");
-    CFX_ByteString abc("abc");
-    CFX_ByteString def("def");
+  CFX_ByteString empty;
+  CFX_ByteString a("a");
+  CFX_ByteString abc("abc");
+  CFX_ByteString def("def");
 
-    EXPECT_FALSE(empty < empty);
-    EXPECT_FALSE(a < a);
-    EXPECT_FALSE(abc < abc);
-    EXPECT_FALSE(def < def);
+  EXPECT_FALSE(empty < empty);
+  EXPECT_FALSE(a < a);
+  EXPECT_FALSE(abc < abc);
+  EXPECT_FALSE(def < def);
 
-    EXPECT_TRUE(empty < a);
-    EXPECT_FALSE(a < empty);
+  EXPECT_TRUE(empty < a);
+  EXPECT_FALSE(a < empty);
 
-    EXPECT_TRUE(empty < abc);
-    EXPECT_FALSE(abc < empty);
+  EXPECT_TRUE(empty < abc);
+  EXPECT_FALSE(abc < empty);
 
-    EXPECT_TRUE(empty < def);
-    EXPECT_FALSE(def < empty);
+  EXPECT_TRUE(empty < def);
+  EXPECT_FALSE(def < empty);
 
-    EXPECT_TRUE(a < abc);
-    EXPECT_FALSE(abc < a);
+  EXPECT_TRUE(a < abc);
+  EXPECT_FALSE(abc < a);
 
-    EXPECT_TRUE(a < def);
-    EXPECT_FALSE(def < a);
+  EXPECT_TRUE(a < def);
+  EXPECT_FALSE(def < a);
 
-    EXPECT_TRUE(abc < def);
-    EXPECT_FALSE(def < abc);
+  EXPECT_TRUE(abc < def);
+  EXPECT_FALSE(def < abc);
 }
 
 TEST(fxcrt, ByteStringOperatorEQ) {
-    CFX_ByteString null_string;
-    EXPECT_TRUE(null_string == null_string);
-
-    CFX_ByteString empty_string("");
-    EXPECT_TRUE(empty_string == empty_string);
-    EXPECT_TRUE(empty_string == null_string);
-    EXPECT_TRUE(null_string == empty_string);
-
-    CFX_ByteString deleted_string("hello");
-    deleted_string.Delete(0, 5);
-    EXPECT_TRUE(deleted_string == deleted_string);
-    EXPECT_TRUE(deleted_string == null_string);
-    EXPECT_TRUE(deleted_string == empty_string);
-    EXPECT_TRUE(null_string == deleted_string);
-    EXPECT_TRUE(empty_string == deleted_string);
-
-    CFX_ByteString byte_string("hello");
-    EXPECT_TRUE(byte_string == byte_string);
-    EXPECT_FALSE(byte_string == null_string);
-    EXPECT_FALSE(byte_string == empty_string);
-    EXPECT_FALSE(byte_string == deleted_string);
-    EXPECT_FALSE(null_string == byte_string);
-    EXPECT_FALSE(empty_string == byte_string);
-    EXPECT_FALSE(deleted_string == byte_string);
-
-    CFX_ByteString byte_string_same1("hello");
-    EXPECT_TRUE(byte_string == byte_string_same1);
-    EXPECT_TRUE(byte_string_same1 == byte_string);
-
-    CFX_ByteString byte_string_same2(byte_string);
-    EXPECT_TRUE(byte_string == byte_string_same2);
-    EXPECT_TRUE(byte_string_same2 == byte_string);
-
-    CFX_ByteString byte_string1("he");
-    CFX_ByteString byte_string2("hellp");
-    CFX_ByteString byte_string3("hellod");
-    EXPECT_FALSE(byte_string == byte_string1);
-    EXPECT_FALSE(byte_string == byte_string2);
-    EXPECT_FALSE(byte_string == byte_string3);
-    EXPECT_FALSE(byte_string1 == byte_string);
-    EXPECT_FALSE(byte_string2 == byte_string);
-    EXPECT_FALSE(byte_string3 == byte_string);
-
-    CFX_ByteStringC null_string_c;
-    CFX_ByteStringC empty_string_c("");
-    EXPECT_TRUE(null_string == null_string_c);
-    EXPECT_TRUE(null_string == empty_string_c);
-    EXPECT_TRUE(empty_string == null_string_c);
-    EXPECT_TRUE(empty_string == empty_string_c);
-    EXPECT_TRUE(deleted_string == null_string_c);
-    EXPECT_TRUE(deleted_string == empty_string_c);
-    EXPECT_TRUE(null_string_c == null_string);
-    EXPECT_TRUE(empty_string_c == null_string);
-    EXPECT_TRUE(null_string_c == empty_string);
-    EXPECT_TRUE(empty_string_c == empty_string);
-    EXPECT_TRUE(null_string_c == deleted_string);
-    EXPECT_TRUE(empty_string_c == deleted_string);
-
-    CFX_ByteStringC byte_string_c_same1("hello");
-    EXPECT_TRUE(byte_string == byte_string_c_same1);
-    EXPECT_TRUE(byte_string_c_same1 == byte_string);
-
-    CFX_ByteStringC byte_string_c1("he");
-    CFX_ByteStringC byte_string_c2("hellp");
-    CFX_ByteStringC byte_string_c3("hellod");
-    EXPECT_FALSE(byte_string == byte_string_c1);
-    EXPECT_FALSE(byte_string == byte_string_c2);
-    EXPECT_FALSE(byte_string == byte_string_c3);
-    EXPECT_FALSE(byte_string_c1 == byte_string);
-    EXPECT_FALSE(byte_string_c2 == byte_string);
-    EXPECT_FALSE(byte_string_c3 == byte_string);
-
-    const char* c_null_string = nullptr;
-    const char* c_empty_string = "";
-    EXPECT_TRUE(null_string == c_null_string);
-    EXPECT_TRUE(null_string == c_empty_string);
-    EXPECT_TRUE(empty_string == c_null_string);
-    EXPECT_TRUE(empty_string == c_empty_string);
-    EXPECT_TRUE(deleted_string == c_null_string);
-    EXPECT_TRUE(deleted_string == c_empty_string);
-    EXPECT_TRUE(c_null_string == null_string);
-    EXPECT_TRUE(c_empty_string == null_string);
-    EXPECT_TRUE(c_null_string == empty_string);
-    EXPECT_TRUE(c_empty_string == empty_string);
-    EXPECT_TRUE(c_null_string == deleted_string);
-    EXPECT_TRUE(c_empty_string == deleted_string);
-
-    const char* c_string_same1 = "hello";
-    EXPECT_TRUE(byte_string == c_string_same1);
-    EXPECT_TRUE(c_string_same1 == byte_string);
-
-    const char* c_string1 = "he";
-    const char* c_string2 = "hellp";
-    const char* c_string3 = "hellod";
-    EXPECT_FALSE(byte_string == c_string1);
-    EXPECT_FALSE(byte_string == c_string2);
-    EXPECT_FALSE(byte_string == c_string3);
-    EXPECT_FALSE(c_string1 == byte_string);
-    EXPECT_FALSE(c_string2 == byte_string);
-    EXPECT_FALSE(c_string3 == byte_string);
+  CFX_ByteString null_string;
+  EXPECT_TRUE(null_string == null_string);
+
+  CFX_ByteString empty_string("");
+  EXPECT_TRUE(empty_string == empty_string);
+  EXPECT_TRUE(empty_string == null_string);
+  EXPECT_TRUE(null_string == empty_string);
+
+  CFX_ByteString deleted_string("hello");
+  deleted_string.Delete(0, 5);
+  EXPECT_TRUE(deleted_string == deleted_string);
+  EXPECT_TRUE(deleted_string == null_string);
+  EXPECT_TRUE(deleted_string == empty_string);
+  EXPECT_TRUE(null_string == deleted_string);
+  EXPECT_TRUE(empty_string == deleted_string);
+
+  CFX_ByteString byte_string("hello");
+  EXPECT_TRUE(byte_string == byte_string);
+  EXPECT_FALSE(byte_string == null_string);
+  EXPECT_FALSE(byte_string == empty_string);
+  EXPECT_FALSE(byte_string == deleted_string);
+  EXPECT_FALSE(null_string == byte_string);
+  EXPECT_FALSE(empty_string == byte_string);
+  EXPECT_FALSE(deleted_string == byte_string);
+
+  CFX_ByteString byte_string_same1("hello");
+  EXPECT_TRUE(byte_string == byte_string_same1);
+  EXPECT_TRUE(byte_string_same1 == byte_string);
+
+  CFX_ByteString byte_string_same2(byte_string);
+  EXPECT_TRUE(byte_string == byte_string_same2);
+  EXPECT_TRUE(byte_string_same2 == byte_string);
+
+  CFX_ByteString byte_string1("he");
+  CFX_ByteString byte_string2("hellp");
+  CFX_ByteString byte_string3("hellod");
+  EXPECT_FALSE(byte_string == byte_string1);
+  EXPECT_FALSE(byte_string == byte_string2);
+  EXPECT_FALSE(byte_string == byte_string3);
+  EXPECT_FALSE(byte_string1 == byte_string);
+  EXPECT_FALSE(byte_string2 == byte_string);
+  EXPECT_FALSE(byte_string3 == byte_string);
+
+  CFX_ByteStringC null_string_c;
+  CFX_ByteStringC empty_string_c("");
+  EXPECT_TRUE(null_string == null_string_c);
+  EXPECT_TRUE(null_string == empty_string_c);
+  EXPECT_TRUE(empty_string == null_string_c);
+  EXPECT_TRUE(empty_string == empty_string_c);
+  EXPECT_TRUE(deleted_string == null_string_c);
+  EXPECT_TRUE(deleted_string == empty_string_c);
+  EXPECT_TRUE(null_string_c == null_string);
+  EXPECT_TRUE(empty_string_c == null_string);
+  EXPECT_TRUE(null_string_c == empty_string);
+  EXPECT_TRUE(empty_string_c == empty_string);
+  EXPECT_TRUE(null_string_c == deleted_string);
+  EXPECT_TRUE(empty_string_c == deleted_string);
+
+  CFX_ByteStringC byte_string_c_same1("hello");
+  EXPECT_TRUE(byte_string == byte_string_c_same1);
+  EXPECT_TRUE(byte_string_c_same1 == byte_string);
+
+  CFX_ByteStringC byte_string_c1("he");
+  CFX_ByteStringC byte_string_c2("hellp");
+  CFX_ByteStringC byte_string_c3("hellod");
+  EXPECT_FALSE(byte_string == byte_string_c1);
+  EXPECT_FALSE(byte_string == byte_string_c2);
+  EXPECT_FALSE(byte_string == byte_string_c3);
+  EXPECT_FALSE(byte_string_c1 == byte_string);
+  EXPECT_FALSE(byte_string_c2 == byte_string);
+  EXPECT_FALSE(byte_string_c3 == byte_string);
+
+  const char* c_null_string = nullptr;
+  const char* c_empty_string = "";
+  EXPECT_TRUE(null_string == c_null_string);
+  EXPECT_TRUE(null_string == c_empty_string);
+  EXPECT_TRUE(empty_string == c_null_string);
+  EXPECT_TRUE(empty_string == c_empty_string);
+  EXPECT_TRUE(deleted_string == c_null_string);
+  EXPECT_TRUE(deleted_string == c_empty_string);
+  EXPECT_TRUE(c_null_string == null_string);
+  EXPECT_TRUE(c_empty_string == null_string);
+  EXPECT_TRUE(c_null_string == empty_string);
+  EXPECT_TRUE(c_empty_string == empty_string);
+  EXPECT_TRUE(c_null_string == deleted_string);
+  EXPECT_TRUE(c_empty_string == deleted_string);
+
+  const char* c_string_same1 = "hello";
+  EXPECT_TRUE(byte_string == c_string_same1);
+  EXPECT_TRUE(c_string_same1 == byte_string);
+
+  const char* c_string1 = "he";
+  const char* c_string2 = "hellp";
+  const char* c_string3 = "hellod";
+  EXPECT_FALSE(byte_string == c_string1);
+  EXPECT_FALSE(byte_string == c_string2);
+  EXPECT_FALSE(byte_string == c_string3);
+  EXPECT_FALSE(c_string1 == byte_string);
+  EXPECT_FALSE(c_string2 == byte_string);
+  EXPECT_FALSE(c_string3 == byte_string);
 }
 
 TEST(fxcrt, ByteStringOperatorNE) {
-    CFX_ByteString null_string;
-    EXPECT_FALSE(null_string != null_string);
-
-    CFX_ByteString empty_string("");
-    EXPECT_FALSE(empty_string != empty_string);
-    EXPECT_FALSE(empty_string != null_string);
-    EXPECT_FALSE(null_string != empty_string);
-
-    CFX_ByteString deleted_string("hello");
-    deleted_string.Delete(0, 5);
-    EXPECT_FALSE(deleted_string != deleted_string);
-    EXPECT_FALSE(deleted_string != null_string);
-    EXPECT_FALSE(deleted_string != empty_string);
-    EXPECT_FALSE(deleted_string != deleted_string);
-    EXPECT_FALSE(null_string != deleted_string);
-    EXPECT_FALSE(empty_string != deleted_string);
-    EXPECT_FALSE(deleted_string != deleted_string);
-
-    CFX_ByteString byte_string("hello");
-    EXPECT_FALSE(byte_string != byte_string);
-    EXPECT_TRUE(byte_string != null_string);
-    EXPECT_TRUE(byte_string != empty_string);
-    EXPECT_TRUE(byte_string != deleted_string);
-    EXPECT_TRUE(null_string != byte_string);
-    EXPECT_TRUE(empty_string != byte_string);
-    EXPECT_TRUE(deleted_string != byte_string);
-
-    CFX_ByteString byte_string_same1("hello");
-    EXPECT_FALSE(byte_string != byte_string_same1);
-    EXPECT_FALSE(byte_string_same1 != byte_string);
-
-    CFX_ByteString byte_string_same2(byte_string);
-    EXPECT_FALSE(byte_string != byte_string_same2);
-    EXPECT_FALSE(byte_string_same2 != byte_string);
-
-    CFX_ByteString byte_string1("he");
-    CFX_ByteString byte_string2("hellp");
-    CFX_ByteString byte_string3("hellod");
-    EXPECT_TRUE(byte_string != byte_string1);
-    EXPECT_TRUE(byte_string != byte_string2);
-    EXPECT_TRUE(byte_string != byte_string3);
-    EXPECT_TRUE(byte_string1 != byte_string);
-    EXPECT_TRUE(byte_string2 != byte_string);
-    EXPECT_TRUE(byte_string3 != byte_string);
-
-    CFX_ByteStringC null_string_c;
-    CFX_ByteStringC empty_string_c("");
-    EXPECT_FALSE(null_string != null_string_c);
-    EXPECT_FALSE(null_string != empty_string_c);
-    EXPECT_FALSE(empty_string != null_string_c);
-    EXPECT_FALSE(empty_string != empty_string_c);
-    EXPECT_FALSE(null_string_c != null_string);
-    EXPECT_FALSE(empty_string_c != null_string);
-    EXPECT_FALSE(null_string_c != empty_string);
-    EXPECT_FALSE(empty_string_c != empty_string);
-
-    CFX_ByteStringC byte_string_c_same1("hello");
-    EXPECT_FALSE(byte_string != byte_string_c_same1);
-    EXPECT_FALSE(byte_string_c_same1 != byte_string);
-
-    CFX_ByteStringC byte_string_c1("he");
-    CFX_ByteStringC byte_string_c2("hellp");
-    CFX_ByteStringC byte_string_c3("hellod");
-    EXPECT_TRUE(byte_string != byte_string_c1);
-    EXPECT_TRUE(byte_string != byte_string_c2);
-    EXPECT_TRUE(byte_string != byte_string_c3);
-    EXPECT_TRUE(byte_string_c1 != byte_string);
-    EXPECT_TRUE(byte_string_c2 != byte_string);
-    EXPECT_TRUE(byte_string_c3 != byte_string);
-
-    const char* c_null_string = nullptr;
-    const char* c_empty_string = "";
-    EXPECT_FALSE(null_string != c_null_string);
-    EXPECT_FALSE(null_string != c_empty_string);
-    EXPECT_FALSE(empty_string != c_null_string);
-    EXPECT_FALSE(empty_string != c_empty_string);
-    EXPECT_FALSE(deleted_string != c_null_string);
-    EXPECT_FALSE(deleted_string != c_empty_string);
-    EXPECT_FALSE(c_null_string != null_string);
-    EXPECT_FALSE(c_empty_string != null_string);
-    EXPECT_FALSE(c_null_string != empty_string);
-    EXPECT_FALSE(c_empty_string != empty_string);
-    EXPECT_FALSE(c_null_string != deleted_string);
-    EXPECT_FALSE(c_empty_string != deleted_string);
-
-    const char* c_string_same1 = "hello";
-    EXPECT_FALSE(byte_string != c_string_same1);
-    EXPECT_FALSE(c_string_same1 != byte_string);
-
-    const char* c_string1 = "he";
-    const char* c_string2 = "hellp";
-    const char* c_string3 = "hellod";
-    EXPECT_TRUE(byte_string != c_string1);
-    EXPECT_TRUE(byte_string != c_string2);
-    EXPECT_TRUE(byte_string != c_string3);
-    EXPECT_TRUE(c_string1 != byte_string);
-    EXPECT_TRUE(c_string2 != byte_string);
-    EXPECT_TRUE(c_string3 != byte_string);
+  CFX_ByteString null_string;
+  EXPECT_FALSE(null_string != null_string);
+
+  CFX_ByteString empty_string("");
+  EXPECT_FALSE(empty_string != empty_string);
+  EXPECT_FALSE(empty_string != null_string);
+  EXPECT_FALSE(null_string != empty_string);
+
+  CFX_ByteString deleted_string("hello");
+  deleted_string.Delete(0, 5);
+  EXPECT_FALSE(deleted_string != deleted_string);
+  EXPECT_FALSE(deleted_string != null_string);
+  EXPECT_FALSE(deleted_string != empty_string);
+  EXPECT_FALSE(deleted_string != deleted_string);
+  EXPECT_FALSE(null_string != deleted_string);
+  EXPECT_FALSE(empty_string != deleted_string);
+  EXPECT_FALSE(deleted_string != deleted_string);
+
+  CFX_ByteString byte_string("hello");
+  EXPECT_FALSE(byte_string != byte_string);
+  EXPECT_TRUE(byte_string != null_string);
+  EXPECT_TRUE(byte_string != empty_string);
+  EXPECT_TRUE(byte_string != deleted_string);
+  EXPECT_TRUE(null_string != byte_string);
+  EXPECT_TRUE(empty_string != byte_string);
+  EXPECT_TRUE(deleted_string != byte_string);
+
+  CFX_ByteString byte_string_same1("hello");
+  EXPECT_FALSE(byte_string != byte_string_same1);
+  EXPECT_FALSE(byte_string_same1 != byte_string);
+
+  CFX_ByteString byte_string_same2(byte_string);
+  EXPECT_FALSE(byte_string != byte_string_same2);
+  EXPECT_FALSE(byte_string_same2 != byte_string);
+
+  CFX_ByteString byte_string1("he");
+  CFX_ByteString byte_string2("hellp");
+  CFX_ByteString byte_string3("hellod");
+  EXPECT_TRUE(byte_string != byte_string1);
+  EXPECT_TRUE(byte_string != byte_string2);
+  EXPECT_TRUE(byte_string != byte_string3);
+  EXPECT_TRUE(byte_string1 != byte_string);
+  EXPECT_TRUE(byte_string2 != byte_string);
+  EXPECT_TRUE(byte_string3 != byte_string);
+
+  CFX_ByteStringC null_string_c;
+  CFX_ByteStringC empty_string_c("");
+  EXPECT_FALSE(null_string != null_string_c);
+  EXPECT_FALSE(null_string != empty_string_c);
+  EXPECT_FALSE(empty_string != null_string_c);
+  EXPECT_FALSE(empty_string != empty_string_c);
+  EXPECT_FALSE(null_string_c != null_string);
+  EXPECT_FALSE(empty_string_c != null_string);
+  EXPECT_FALSE(null_string_c != empty_string);
+  EXPECT_FALSE(empty_string_c != empty_string);
+
+  CFX_ByteStringC byte_string_c_same1("hello");
+  EXPECT_FALSE(byte_string != byte_string_c_same1);
+  EXPECT_FALSE(byte_string_c_same1 != byte_string);
+
+  CFX_ByteStringC byte_string_c1("he");
+  CFX_ByteStringC byte_string_c2("hellp");
+  CFX_ByteStringC byte_string_c3("hellod");
+  EXPECT_TRUE(byte_string != byte_string_c1);
+  EXPECT_TRUE(byte_string != byte_string_c2);
+  EXPECT_TRUE(byte_string != byte_string_c3);
+  EXPECT_TRUE(byte_string_c1 != byte_string);
+  EXPECT_TRUE(byte_string_c2 != byte_string);
+  EXPECT_TRUE(byte_string_c3 != byte_string);
+
+  const char* c_null_string = nullptr;
+  const char* c_empty_string = "";
+  EXPECT_FALSE(null_string != c_null_string);
+  EXPECT_FALSE(null_string != c_empty_string);
+  EXPECT_FALSE(empty_string != c_null_string);
+  EXPECT_FALSE(empty_string != c_empty_string);
+  EXPECT_FALSE(deleted_string != c_null_string);
+  EXPECT_FALSE(deleted_string != c_empty_string);
+  EXPECT_FALSE(c_null_string != null_string);
+  EXPECT_FALSE(c_empty_string != null_string);
+  EXPECT_FALSE(c_null_string != empty_string);
+  EXPECT_FALSE(c_empty_string != empty_string);
+  EXPECT_FALSE(c_null_string != deleted_string);
+  EXPECT_FALSE(c_empty_string != deleted_string);
+
+  const char* c_string_same1 = "hello";
+  EXPECT_FALSE(byte_string != c_string_same1);
+  EXPECT_FALSE(c_string_same1 != byte_string);
+
+  const char* c_string1 = "he";
+  const char* c_string2 = "hellp";
+  const char* c_string3 = "hellod";
+  EXPECT_TRUE(byte_string != c_string1);
+  EXPECT_TRUE(byte_string != c_string2);
+  EXPECT_TRUE(byte_string != c_string3);
+  EXPECT_TRUE(c_string1 != byte_string);
+  EXPECT_TRUE(c_string2 != byte_string);
+  EXPECT_TRUE(c_string3 != byte_string);
 }
 
 TEST(fxcrt, ByteStringCNull) {
@@ -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");
@@ -382,8 +409,8 @@ TEST(fxcrt, ByteStringCGetID) {
   EXPECT_EQ(FXBSTR_ID('b', 'c', 'd', 'e'), longer_string.GetID(1));
   EXPECT_EQ(FXBSTR_ID('c', 'd', 'e', 'f'), longer_string.GetID(2));
   EXPECT_EQ(FXBSTR_ID('d', 'e', 'f', 0), longer_string.GetID(3));
-  EXPECT_EQ(FXBSTR_ID('e', 'f', 0 , 0), longer_string.GetID(4));
-  EXPECT_EQ(FXBSTR_ID('f', 0 , 0, 0), longer_string.GetID(5));
+  EXPECT_EQ(FXBSTR_ID('e', 'f', 0, 0), longer_string.GetID(4));
+  EXPECT_EQ(FXBSTR_ID('f', 0, 0, 0), longer_string.GetID(5));
   EXPECT_EQ(0u, longer_string.GetID(6));
   EXPECT_EQ(0u, longer_string.GetID(-1));
   EXPECT_EQ(0u, longer_string.GetID(-1000000));
@@ -435,144 +462,144 @@ TEST(fxcrt, ByteStringCGetAt) {
 }
 
 TEST(fxcrt, ByteStringCOperatorSubscript) {
-    // CFX_ByteStringC includes the NUL terminator for non-empty strings.
-    CFX_ByteStringC abc("abc");
-    EXPECT_EQ('a', abc[0]);
-    EXPECT_EQ('b', abc[1]);
-    EXPECT_EQ('c', abc[2]);
-    EXPECT_EQ(0, abc[3]);
+  // CFX_ByteStringC includes the NUL terminator for non-empty strings.
+  CFX_ByteStringC abc("abc");
+  EXPECT_EQ('a', abc[0]);
+  EXPECT_EQ('b', abc[1]);
+  EXPECT_EQ('c', abc[2]);
+  EXPECT_EQ(0, abc[3]);
 }
 
 TEST(fxcrt, ByteStringCOperatorLT) {
-    CFX_ByteStringC empty;
-    CFX_ByteStringC a("a");
-    CFX_ByteStringC abc("abc");
-    CFX_ByteStringC def("def");
+  CFX_ByteStringC empty;
+  CFX_ByteStringC a("a");
+  CFX_ByteStringC abc("abc");
+  CFX_ByteStringC def("def");
 
-    EXPECT_FALSE(empty < empty);
-    EXPECT_FALSE(a < a);
-    EXPECT_FALSE(abc < abc);
-    EXPECT_FALSE(def < def);
+  EXPECT_FALSE(empty < empty);
+  EXPECT_FALSE(a < a);
+  EXPECT_FALSE(abc < abc);
+  EXPECT_FALSE(def < def);
 
-    EXPECT_TRUE(empty < a);
-    EXPECT_FALSE(a < empty);
+  EXPECT_TRUE(empty < a);
+  EXPECT_FALSE(a < empty);
 
-    EXPECT_TRUE(empty < abc);
-    EXPECT_FALSE(abc < empty);
+  EXPECT_TRUE(empty < abc);
+  EXPECT_FALSE(abc < empty);
 
-    EXPECT_TRUE(empty < def);
-    EXPECT_FALSE(def < empty);
+  EXPECT_TRUE(empty < def);
+  EXPECT_FALSE(def < empty);
 
-    EXPECT_TRUE(a < abc);
-    EXPECT_FALSE(abc < a);
+  EXPECT_TRUE(a < abc);
+  EXPECT_FALSE(abc < a);
 
-    EXPECT_TRUE(a < def);
-    EXPECT_FALSE(def < a);
+  EXPECT_TRUE(a < def);
+  EXPECT_FALSE(def < a);
 
-    EXPECT_TRUE(abc < def);
-    EXPECT_FALSE(def < abc);
+  EXPECT_TRUE(abc < def);
+  EXPECT_FALSE(def < abc);
 }
 
 TEST(fxcrt, ByteStringCOperatorEQ) {
-    CFX_ByteStringC byte_string_c("hello");
-    EXPECT_TRUE(byte_string_c == byte_string_c);
-
-    CFX_ByteStringC byte_string_c_same1("hello");
-    EXPECT_TRUE(byte_string_c == byte_string_c_same1);
-    EXPECT_TRUE(byte_string_c_same1 == byte_string_c);
-
-    CFX_ByteStringC byte_string_c_same2(byte_string_c);
-    EXPECT_TRUE(byte_string_c == byte_string_c_same2);
-    EXPECT_TRUE(byte_string_c_same2 == byte_string_c);
-
-    CFX_ByteStringC byte_string_c1("he");
-    CFX_ByteStringC byte_string_c2("hellp");
-    CFX_ByteStringC byte_string_c3("hellod");
-    EXPECT_FALSE(byte_string_c == byte_string_c1);
-    EXPECT_FALSE(byte_string_c == byte_string_c2);
-    EXPECT_FALSE(byte_string_c == byte_string_c3);
-    EXPECT_FALSE(byte_string_c1 == byte_string_c);
-    EXPECT_FALSE(byte_string_c2 == byte_string_c);
-    EXPECT_FALSE(byte_string_c3 == byte_string_c);
-
-    CFX_ByteString byte_string_same1("hello");
-    EXPECT_TRUE(byte_string_c == byte_string_same1);
-    EXPECT_TRUE(byte_string_same1 == byte_string_c);
-
-    CFX_ByteString byte_string1("he");
-    CFX_ByteString byte_string2("hellp");
-    CFX_ByteString byte_string3("hellod");
-    EXPECT_FALSE(byte_string_c == byte_string1);
-    EXPECT_FALSE(byte_string_c == byte_string2);
-    EXPECT_FALSE(byte_string_c == byte_string3);
-    EXPECT_FALSE(byte_string1 == byte_string_c);
-    EXPECT_FALSE(byte_string2 == byte_string_c);
-    EXPECT_FALSE(byte_string3 == byte_string_c);
-
-    const char* c_string_same1 = "hello";
-    EXPECT_TRUE(byte_string_c == c_string_same1);
-    EXPECT_TRUE(c_string_same1 == byte_string_c);
-
-    const char* c_string1 = "he";
-    const char* c_string2 = "hellp";
-    const char* c_string3 = "hellod";
-    EXPECT_FALSE(byte_string_c == c_string1);
-    EXPECT_FALSE(byte_string_c == c_string2);
-    EXPECT_FALSE(byte_string_c == c_string3);
-
-    EXPECT_FALSE(c_string1 == byte_string_c);
-    EXPECT_FALSE(c_string2 == byte_string_c);
-    EXPECT_FALSE(c_string3 == byte_string_c);
+  CFX_ByteStringC byte_string_c("hello");
+  EXPECT_TRUE(byte_string_c == byte_string_c);
+
+  CFX_ByteStringC byte_string_c_same1("hello");
+  EXPECT_TRUE(byte_string_c == byte_string_c_same1);
+  EXPECT_TRUE(byte_string_c_same1 == byte_string_c);
+
+  CFX_ByteStringC byte_string_c_same2(byte_string_c);
+  EXPECT_TRUE(byte_string_c == byte_string_c_same2);
+  EXPECT_TRUE(byte_string_c_same2 == byte_string_c);
+
+  CFX_ByteStringC byte_string_c1("he");
+  CFX_ByteStringC byte_string_c2("hellp");
+  CFX_ByteStringC byte_string_c3("hellod");
+  EXPECT_FALSE(byte_string_c == byte_string_c1);
+  EXPECT_FALSE(byte_string_c == byte_string_c2);
+  EXPECT_FALSE(byte_string_c == byte_string_c3);
+  EXPECT_FALSE(byte_string_c1 == byte_string_c);
+  EXPECT_FALSE(byte_string_c2 == byte_string_c);
+  EXPECT_FALSE(byte_string_c3 == byte_string_c);
+
+  CFX_ByteString byte_string_same1("hello");
+  EXPECT_TRUE(byte_string_c == byte_string_same1);
+  EXPECT_TRUE(byte_string_same1 == byte_string_c);
+
+  CFX_ByteString byte_string1("he");
+  CFX_ByteString byte_string2("hellp");
+  CFX_ByteString byte_string3("hellod");
+  EXPECT_FALSE(byte_string_c == byte_string1);
+  EXPECT_FALSE(byte_string_c == byte_string2);
+  EXPECT_FALSE(byte_string_c == byte_string3);
+  EXPECT_FALSE(byte_string1 == byte_string_c);
+  EXPECT_FALSE(byte_string2 == byte_string_c);
+  EXPECT_FALSE(byte_string3 == byte_string_c);
+
+  const char* c_string_same1 = "hello";
+  EXPECT_TRUE(byte_string_c == c_string_same1);
+  EXPECT_TRUE(c_string_same1 == byte_string_c);
+
+  const char* c_string1 = "he";
+  const char* c_string2 = "hellp";
+  const char* c_string3 = "hellod";
+  EXPECT_FALSE(byte_string_c == c_string1);
+  EXPECT_FALSE(byte_string_c == c_string2);
+  EXPECT_FALSE(byte_string_c == c_string3);
+
+  EXPECT_FALSE(c_string1 == byte_string_c);
+  EXPECT_FALSE(c_string2 == byte_string_c);
+  EXPECT_FALSE(c_string3 == byte_string_c);
 }
 
 TEST(fxcrt, ByteStringCOperatorNE) {
-    CFX_ByteStringC byte_string_c("hello");
-    EXPECT_FALSE(byte_string_c != byte_string_c);
-
-    CFX_ByteStringC byte_string_c_same1("hello");
-    EXPECT_FALSE(byte_string_c != byte_string_c_same1);
-    EXPECT_FALSE(byte_string_c_same1 != byte_string_c);
-
-    CFX_ByteStringC byte_string_c_same2(byte_string_c);
-    EXPECT_FALSE(byte_string_c != byte_string_c_same2);
-    EXPECT_FALSE(byte_string_c_same2 != byte_string_c);
-
-    CFX_ByteStringC byte_string_c1("he");
-    CFX_ByteStringC byte_string_c2("hellp");
-    CFX_ByteStringC byte_string_c3("hellod");
-    EXPECT_TRUE(byte_string_c != byte_string_c1);
-    EXPECT_TRUE(byte_string_c != byte_string_c2);
-    EXPECT_TRUE(byte_string_c != byte_string_c3);
-    EXPECT_TRUE(byte_string_c1 != byte_string_c);
-    EXPECT_TRUE(byte_string_c2 != byte_string_c);
-    EXPECT_TRUE(byte_string_c3 != byte_string_c);
-
-    CFX_ByteString byte_string_same1("hello");
-    EXPECT_FALSE(byte_string_c != byte_string_same1);
-    EXPECT_FALSE(byte_string_same1 != byte_string_c);
-
-    CFX_ByteString byte_string1("he");
-    CFX_ByteString byte_string2("hellp");
-    CFX_ByteString byte_string3("hellod");
-    EXPECT_TRUE(byte_string_c != byte_string1);
-    EXPECT_TRUE(byte_string_c != byte_string2);
-    EXPECT_TRUE(byte_string_c != byte_string3);
-    EXPECT_TRUE(byte_string1 != byte_string_c);
-    EXPECT_TRUE(byte_string2 != byte_string_c);
-    EXPECT_TRUE(byte_string3 != byte_string_c);
-
-    const char* c_string_same1 = "hello";
-    EXPECT_FALSE(byte_string_c != c_string_same1);
-    EXPECT_FALSE(c_string_same1 != byte_string_c);
-
-    const char* c_string1 = "he";
-    const char* c_string2 = "hellp";
-    const char* c_string3 = "hellod";
-    EXPECT_TRUE(byte_string_c != c_string1);
-    EXPECT_TRUE(byte_string_c != c_string2);
-    EXPECT_TRUE(byte_string_c != c_string3);
-
-    EXPECT_TRUE(c_string1 != byte_string_c);
-    EXPECT_TRUE(c_string2 != byte_string_c);
-    EXPECT_TRUE(c_string3 != byte_string_c);
+  CFX_ByteStringC byte_string_c("hello");
+  EXPECT_FALSE(byte_string_c != byte_string_c);
+
+  CFX_ByteStringC byte_string_c_same1("hello");
+  EXPECT_FALSE(byte_string_c != byte_string_c_same1);
+  EXPECT_FALSE(byte_string_c_same1 != byte_string_c);
+
+  CFX_ByteStringC byte_string_c_same2(byte_string_c);
+  EXPECT_FALSE(byte_string_c != byte_string_c_same2);
+  EXPECT_FALSE(byte_string_c_same2 != byte_string_c);
+
+  CFX_ByteStringC byte_string_c1("he");
+  CFX_ByteStringC byte_string_c2("hellp");
+  CFX_ByteStringC byte_string_c3("hellod");
+  EXPECT_TRUE(byte_string_c != byte_string_c1);
+  EXPECT_TRUE(byte_string_c != byte_string_c2);
+  EXPECT_TRUE(byte_string_c != byte_string_c3);
+  EXPECT_TRUE(byte_string_c1 != byte_string_c);
+  EXPECT_TRUE(byte_string_c2 != byte_string_c);
+  EXPECT_TRUE(byte_string_c3 != byte_string_c);
+
+  CFX_ByteString byte_string_same1("hello");
+  EXPECT_FALSE(byte_string_c != byte_string_same1);
+  EXPECT_FALSE(byte_string_same1 != byte_string_c);
+
+  CFX_ByteString byte_string1("he");
+  CFX_ByteString byte_string2("hellp");
+  CFX_ByteString byte_string3("hellod");
+  EXPECT_TRUE(byte_string_c != byte_string1);
+  EXPECT_TRUE(byte_string_c != byte_string2);
+  EXPECT_TRUE(byte_string_c != byte_string3);
+  EXPECT_TRUE(byte_string1 != byte_string_c);
+  EXPECT_TRUE(byte_string2 != byte_string_c);
+  EXPECT_TRUE(byte_string3 != byte_string_c);
+
+  const char* c_string_same1 = "hello";
+  EXPECT_FALSE(byte_string_c != c_string_same1);
+  EXPECT_FALSE(c_string_same1 != byte_string_c);
+
+  const char* c_string1 = "he";
+  const char* c_string2 = "hellp";
+  const char* c_string3 = "hellod";
+  EXPECT_TRUE(byte_string_c != c_string1);
+  EXPECT_TRUE(byte_string_c != c_string2);
+  EXPECT_TRUE(byte_string_c != c_string3);
+
+  EXPECT_TRUE(c_string1 != byte_string_c);
+  EXPECT_TRUE(c_string2 != byte_string_c);
+  EXPECT_TRUE(c_string3 != byte_string_c);
 }