diff --git a/src/libs/utils/smallstringview.h b/src/libs/utils/smallstringview.h index 2320ef99b6b..3d479195f17 100644 --- a/src/libs/utils/smallstringview.h +++ b/src/libs/utils/smallstringview.h @@ -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 { diff --git a/tests/unit/unittest/smallstring-test.cpp b/tests/unit/unittest/smallstring-test.cpp index 64273c45b2e..345480182bc 100644 --- a/tests/unit/unittest/smallstring-test.cpp +++ b/tests/unit/unittest/smallstring-test.cpp @@ -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());