From 7ff956c426bda502983c78b42e83437e040da8fe Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 22 Jan 2024 13:50:34 +0100 Subject: [PATCH] QJniArray: add missing post-increment operator Augment test case. Found during header review. Task-number: QTBUG-119952 Change-Id: I326395397167edb05ff1f45f7151614c02b7e7eb Reviewed-by: Marc Mutz (cherry picked from commit e5074cd3540e165f771aa5bfea36d09553eadc77) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qjniarray.h | 6 ++++++ tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h index bf09e9db63a..748830a04ea 100644 --- a/src/corelib/kernel/qjniarray.h +++ b/src/corelib/kernel/qjniarray.h @@ -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 { diff --git a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp index 6e05dd27a83..65dd832e92e 100644 --- a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp +++ b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp @@ -92,6 +92,17 @@ void tst_QJniArray::operators() QJniArray 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::const_iterator it = {}; QCOMPARE(it, QJniArray::const_iterator{});