Commit 381b51c0 authored by Marco Bubke's avatar Marco Bubke

Utils: Add toView to SmallString

Change-Id: I242a3a8e8411dfca19e50279928f97a5623e55d4
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 24e5dd05
......@@ -232,6 +232,11 @@ public:
return QString::fromUtf8(data(), int(size()));
}
SmallStringView toView() const
{
return SmallStringView(data(), size());
}
operator SmallStringView() const
{
return SmallStringView(data(), size());
......
......@@ -1375,6 +1375,16 @@ TEST(SmallString, ShortStringCapacity)
ASSERT_THAT(PathString().shortStringCapacity(), 189);
}
TEST(SmallString, ToView)
{
SmallString text = "text";
auto view = text.toView();
ASSERT_THAT(view, "text");
}
TEST(SmallString, Compare)
{
ASSERT_THAT(Utils::compare("", ""), Eq(0));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment