summaryrefslogtreecommitdiff
path: root/core/fxcrt/widestring_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/widestring_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/widestring_unittest.cpp')
-rw-r--r--core/fxcrt/widestring_unittest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 4572305530..b044a81bb0 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -53,6 +53,37 @@ TEST(WideString, ElementAccess) {
#endif
}
+TEST(WideString, Assign) {
+ {
+ // Copy-assign.
+ WideString string1;
+ EXPECT_EQ(0, string1.ReferenceCountForTesting());
+ {
+ WideString string2(L"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.
+ WideString string1;
+ EXPECT_EQ(0, string1.ReferenceCountForTesting());
+ {
+ WideString string2(L"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(WideString, OperatorLT) {
WideString empty;
WideString a(L"a");