From d013aa16ef4255d01a6704102e00555fc7167b03 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 5 Feb 2020 15:11:54 +0100 Subject: Extend QContiguousCache to use qsizetype for size and indices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow for more than 2^31 items and large offsets. Change-Id: I42f7bf20ce0e4af43dbb2e2083abf0e232e68282 Reviewed-by: MÃ¥rten Nordheim --- .../qcontiguouscache/tst_qcontiguouscache.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp') diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index f305d63d46..b25ed55648 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -106,25 +106,25 @@ void tst_QContiguousCache::swap() void tst_QContiguousCache::append_data() { - QTest::addColumn("start"); - QTest::addColumn("count"); - QTest::addColumn("cacheSize"); + QTest::addColumn("start"); + QTest::addColumn("count"); + QTest::addColumn("cacheSize"); QTest::addColumn("invalidIndexes"); - QTest::newRow("0+30[10]") << 0 << 30 << 10 << false; - QTest::newRow("300+30[10]") << 300 << 30 << 10 << false; - QTest::newRow("MAX-10+30[10]") << INT_MAX-10 << 30 << 10 << true; + QTest::newRow("0+30[10]") << qsizetype(0) << qsizetype(30) << qsizetype(10) << false; + QTest::newRow("300+30[10]") << qsizetype(300) << qsizetype(30) << qsizetype(10) << false; + QTest::newRow("MAX-10+30[10]") << std::numeric_limits::max()-10 << qsizetype(30) << qsizetype(10) << true; } void tst_QContiguousCache::append() { - QFETCH(int, start); - QFETCH(int, count); - QFETCH(int, cacheSize); + QFETCH(qsizetype, start); + QFETCH(qsizetype, count); + QFETCH(qsizetype, cacheSize); QFETCH(bool, invalidIndexes); - int i, j; - QContiguousCache c(cacheSize); + qsizetype i, j; + QContiguousCache c(cacheSize); i = 1; QCOMPARE(c.available(), cacheSize); @@ -134,8 +134,8 @@ void tst_QContiguousCache::append() c.insert(start, i++); while (i < count) { c.append(i); - QCOMPARE(c.available(), qMax(0, cacheSize - i)); - QCOMPARE(c.first(), qMax(1, i-cacheSize+1)); + QCOMPARE(c.available(), qMax(qsizetype(0), cacheSize - i)); + QCOMPARE(c.first(), qMax(qsizetype(1), i-cacheSize+1)); QCOMPARE(c.last(), i); QCOMPARE(c.count(), qMin(i, cacheSize)); QCOMPARE(c.isFull(), i >= cacheSize); -- cgit v1.2.3