summaryrefslogtreecommitdiff
path: root/core/fxcrt/bytestring_unittest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-19 14:37:12 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-19 14:37:12 +0000
commita1ea4276f87f945dfe922f7c37c08f2d203e4e59 (patch)
tree125f9e604c64f1bd38f8ff44d8784b062f0245c4 /core/fxcrt/bytestring_unittest.cpp
parentee3e3a4f3cbaa99ae3609f575ff9b2c329c5df2a (diff)
downloadpdfium-a1ea4276f87f945dfe922f7c37c08f2d203e4e59.tar.xz
fxcrt::{Byte,Wide}String missing move-assign operator
This hasn't been a big deal, since no data is copied, but avoids some ref-count churn in the process. Change-Id: I53c059284aa6806793c59a0c19b3e0d7fe4191d6 Reviewed-on: https://pdfium-review.googlesource.com/35350 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/bytestring_unittest.cpp')
-rw-r--r--core/fxcrt/bytestring_unittest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index ed3f375434..2b7d4f7836 100644
--- a/core/fxcrt/bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -59,6 +59,37 @@ TEST(ByteString, ElementAccess) {
#endif
}
+TEST(ByteString, Assign) {
+ {
+ // Copy-assign.
+ ByteString string1;
+ EXPECT_EQ(0, string1.ReferenceCountForTesting());
+ {
+ ByteString string2("abc");
+ EXPECT_EQ(1, string2.ReferenceCountForTesting());
+
+ string1 = string2;
+ EXPECT_EQ(2, string1.ReferenceCountForTesting());
+ EXPECT_EQ(2, string2.ReferenceCountForTesting());
+ }
+ EXPECT_EQ(1, string1.ReferenceCountForTesting());
+ }
+ {
+ // Move-assign.
+ ByteString string1;
+ EXPECT_EQ(0, string1.ReferenceCountForTesting());
+ {
+ ByteString string2("abc");
+ EXPECT_EQ(1, string2.ReferenceCountForTesting());
+
+ string1 = std::move(string2);
+ EXPECT_EQ(1, string1.ReferenceCountForTesting());
+ EXPECT_EQ(0, string2.ReferenceCountForTesting());
+ }
+ EXPECT_EQ(1, string1.ReferenceCountForTesting());
+ }
+}
+
TEST(ByteString, OperatorLT) {
ByteString empty;
ByteString a("a");