Commit 19a00f41 authored by Marco Bubke's avatar Marco Bubke

Utils: Add const reverse iterators to SmallString

Change-Id: Iefd9d6abafbe38dcb7d3ed9ea200ac3244902433
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 8a161516
......@@ -299,6 +299,16 @@ public:
return reverse_iterator(begin() - static_cast<std::size_t>(1));
}
const_reverse_iterator rbegin() const noexcept
{
return const_reverse_iterator(end() - static_cast<std::size_t>(1));
}
const_reverse_iterator rend() const noexcept
{
return const_reverse_iterator(begin() - static_cast<std::size_t>(1));
}
const_iterator begin() const noexcept
{
return constData();
......
......@@ -317,6 +317,29 @@ TEST(SmallString, RBeginPlusOneIsEqualREndForSmallStringWidthSizeOne)
ASSERT_THAT(beginPlusOne, Eq(text.rend()));
}
TEST(SmallString, ConstRBeginIsEqualREndForEmptySmallString)
{
const SmallString text;
ASSERT_THAT(text.rbegin(), Eq(text.rend()));
}
TEST(SmallString, ConstRBeginIsNotEqualREndForNonEmptySmallString)
{
const SmallString text("x");
ASSERT_THAT(text.rbegin(), Ne(text.rend()));
}
TEST(SmallString, ConstRBeginPlusOneIsEqualREndForSmallStringWidthSizeOne)
{
const SmallString text("x");
auto beginPlusOne = text.rbegin() + 1l;
ASSERT_THAT(beginPlusOne, Eq(text.rend()));
}
TEST(SmallString, ConstructorStandardString)
{
std::string stdStringText = "short string";
......
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