Utils: Add + operator to SmallString

It should not be used for chained concatenation. Use initializer list
instead.

auto text = in + 'x';

auto text = Utils::SmallString{in, "x", other, ", "};

Change-Id: I453d986913eae89fd5e1f525b9f4e0c4bd089467
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-07-31 17:24:07 +02:00
parent 1b14ec5056
commit 01e1f13bb9
2 changed files with 84 additions and 0 deletions

View File

@@ -1269,3 +1269,21 @@ TEST(SmallString, NumberToString)
ASSERT_THAT(SmallString::number(1.2), "1.200000");
ASSERT_THAT(SmallString::number(-1.2), "-1.200000");
}
TEST(SmallString, StringViewPlusOperator)
{
SmallStringView text = "text";
auto result = text + " and more text";
ASSERT_THAT(result, "text and more text");
}
TEST(SmallString, StringPlusOperator)
{
SmallString text = "text";
auto result = text + " and more text";
ASSERT_THAT(result, "text and more text");
}