forked from qt-creator/qt-creator
Utils: Add carriage return strip method to SmallString
Sometimes you want to compare unix and windows texts in tests. This is a convenient function to remove the carriage returns. Change-Id: I164298b70d3d775dd45903ea3753ac0e68ed2fdc Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -472,6 +472,15 @@ public:
|
|||||||
setSize(newSize);
|
setSize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BasicSmallString toCarriageReturnsStripped() const
|
||||||
|
{
|
||||||
|
BasicSmallString text = *this;
|
||||||
|
|
||||||
|
text.replace("\r", "");
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr static
|
constexpr static
|
||||||
size_type shortStringCapacity() noexcept
|
size_type shortStringCapacity() noexcept
|
||||||
{
|
{
|
||||||
|
@@ -1050,3 +1050,12 @@ TEST(SmallString, ReplaceByPositionEqualSizedTexts)
|
|||||||
ASSERT_THAT(text, SmallString("this is very very very very very much text"));
|
ASSERT_THAT(text, SmallString("this is very very very very very much text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SmallString, CompareTextWithDifferentLineEndings)
|
||||||
|
{
|
||||||
|
SmallString unixText("some \ntext");
|
||||||
|
SmallString windowsText("some \n\rtext");
|
||||||
|
|
||||||
|
auto convertedText = windowsText.toCarriageReturnsStripped();
|
||||||
|
|
||||||
|
ASSERT_THAT(unixText, convertedText);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user