diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-01-22 13:50:34 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-01-29 16:06:47 +0100 |
commit | e5074cd3540e165f771aa5bfea36d09553eadc77 (patch) | |
tree | e4206ffd834171e3c625ba749a6045e3a5244080 | |
parent | 8f04615bcddbe4d8d00f2f7e977e13f93f90fddb (diff) |
QJniArray: add missing post-increment operator
Augment test case. Found during header review.
Pick-to: 6.7
Task-number: QTBUG-119952
Change-Id: I326395397167edb05ff1f45f7151614c02b7e7eb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | src/corelib/kernel/qjniarray.h | 6 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h index 0c8dcc395d..434d27e180 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 6e05dd27a8..65dd832e92 100644 --- a/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp +++ b/tests/auto/corelib/kernel/qjniarray/tst_qjniarray.cpp @@ -93,6 +93,17 @@ void tst_QJniArray::operators() 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{}); QCOMPARE_NE(array.begin(), array.end()); |