forked from qt-creator/qt-creator
Utils: Fix small string
Change-Id: I6a746eb28c6c803b9ade9f626a950cf93ba6fe99 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -615,7 +615,13 @@ public:
|
||||
|
||||
friend BasicSmallString operator+(SmallStringView first, const BasicSmallString &second)
|
||||
{
|
||||
return operator+(second, first);
|
||||
BasicSmallString text;
|
||||
text.reserve(first.size() + second.size());
|
||||
|
||||
text.append(first);
|
||||
text.append(second);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
template<size_type ArraySize>
|
||||
|
||||
@@ -1657,6 +1657,15 @@ TEST(SmallString, StringViewPlusOperator)
|
||||
ASSERT_THAT(result, "text and more text");
|
||||
}
|
||||
|
||||
TEST(SmallString, StringViewPlusOperatorReverseOrder)
|
||||
{
|
||||
SmallStringView text = " and more text";
|
||||
|
||||
auto result = "text" + text;
|
||||
|
||||
ASSERT_THAT(result, "text and more text");
|
||||
}
|
||||
|
||||
TEST(SmallString, StringPlusOperator)
|
||||
{
|
||||
SmallString text = "text";
|
||||
@@ -1666,6 +1675,15 @@ TEST(SmallString, StringPlusOperator)
|
||||
ASSERT_THAT(result, "text and more text");
|
||||
}
|
||||
|
||||
TEST(SmallString, StringPlusOperatorReverseOrder)
|
||||
{
|
||||
SmallString text = " and more text";
|
||||
|
||||
auto result = "text" + text;
|
||||
|
||||
ASSERT_THAT(result, "text and more text");
|
||||
}
|
||||
|
||||
TEST(SmallString, ShortStringCapacity)
|
||||
{
|
||||
ASSERT_THAT(SmallString().shortStringCapacity(), 30);
|
||||
|
||||
Reference in New Issue
Block a user