QJniArray: add missing post-increment operator

Augment test case. Found during header review.

Task-number: QTBUG-119952
Change-Id: I326395397167edb05ff1f45f7151614c02b7e7eb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e5074cd3540e165f771aa5bfea36d09553eadc77)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-01-22 13:50:34 +01:00 committed by Qt Cherry-pick Bot
parent ee895907f8
commit 7ff956c426
2 changed files with 17 additions and 0 deletions

View File

@ -50,6 +50,12 @@ struct QJniArrayIterator
++that.m_index;
return that;
}
friend QJniArrayIterator operator++(QJniArrayIterator &that, int) noexcept
{
auto copy = that;
++that;
return copy;
}
void swap(QJniArrayIterator &other) noexcept
{

View File

@ -92,6 +92,17 @@ void tst_QJniArray::operators()
QJniArray<jbyte> array(bytes);
QVERIFY(array.isValid());
{
auto it = array.begin();
QCOMPARE(*it, 'a');
QCOMPARE(*++it, 'b');
QCOMPARE(*it++, 'b');
QCOMPARE(*it, 'c');
++it;
it++;
QCOMPARE(*it, 'e');
QCOMPARE(++it, array.end());
}
{
QJniArray<jbyte>::const_iterator it = {};
QCOMPARE(it, QJniArray<jbyte>::const_iterator{});