Utils: Add isEmpty to string view

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

View File

@@ -85,6 +85,12 @@ public:
return m_size;
}
constexpr
size_type isEmpty() const
{
return m_size == 0;
}
const_iterator begin() const noexcept
{
return data();

View File

@@ -731,6 +731,12 @@ TEST(SmallString, IsEmpty)
ASSERT_TRUE(SmallString().isEmpty());
}
TEST(SmallString, StringViewIsEmpty)
{
ASSERT_FALSE(SmallStringView("text").isEmpty());
ASSERT_TRUE(SmallStringView("").isEmpty());
}
TEST(SmallString, HasContent)
{
ASSERT_TRUE(SmallString("text").hasContent());