forked from qt-creator/qt-creator
Utils: Add const reverse iterators to SmallString
Change-Id: Iefd9d6abafbe38dcb7d3ed9ea200ac3244902433 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -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";
|
||||
|
Reference in New Issue
Block a user