Utils: Add Utils::SmallStringView::empty

It is required by many template function because it is used in the STL.

Change-Id: I5a2b9266d0c9d79bdc37cbbc4e7b62fac7a82b8b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-09-21 11:34:41 +02:00
parent 816a9175be
commit 2fc4e17e31
2 changed files with 12 additions and 0 deletions

View File

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

View File

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