Utils: Fix smallstring move assignment

Before the string was simply swapped with the other string which can lead
to an unexpected behavior for xvalues. Now the destructor of the source is
called and it is default initialized.

foo = std::move(bar);

bar would now hold the value of foo.

Change-Id: Ibea3f18333a168634b7faf2fdaf9b5b52c82d5cc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-10-16 11:15:46 +02:00
parent 1d53110402
commit ce4d7e9d0e
2 changed files with 7 additions and 4 deletions

View File

@@ -1495,7 +1495,7 @@ TEST(SmallString, ShortSmallStringMoveAssignment)
copy = std::move(text);
ASSERT_THAT(text, SmallString("more text"));
ASSERT_THAT(text, IsEmpty());
ASSERT_THAT(copy, SmallString("text"));
}
@@ -1506,7 +1506,7 @@ TEST(SmallString, LongSmallStringMoveAssignment)
copy = std::move(text);
ASSERT_THAT(text, SmallString("more text"));
ASSERT_THAT(text, IsEmpty());
ASSERT_THAT(copy, SmallString("this is a very very very very long text"));
}