From 320c4e31e124f99601399d00935362b587c77510 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Sep 2012 16:30:48 +0200 Subject: Make QContiguousCache with zero capacity not crash These containers don't make sense and will just result in no action being taken (all items added will simply be discarded), but it shouldn't crash due to a division by zero. Update the documentation to explain the fact. Task-number: QTBUG-27339 Change-Id: Ib9acf5c0a9a826e6853e7beaf5e56511fde98dc6 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Ian Walters Reviewed-by: Thiago Macieira --- .../tools/qcontiguouscache/tst_qcontiguouscache.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index d6e8b87383..f813a687cd 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -67,6 +67,7 @@ private slots: void setCapacity(); void zeroCapacity(); + void modifyZeroCapacityCache(); }; QTEST_MAIN(tst_QContiguousCache) @@ -365,4 +366,24 @@ void tst_QContiguousCache::zeroCapacity() QCOMPARE(contiguousCache.capacity(),0); } +void tst_QContiguousCache::modifyZeroCapacityCache() +{ + { + QContiguousCache contiguousCache; + contiguousCache.insert(0, 42); + } + { + QContiguousCache contiguousCache; + contiguousCache.insert(1, 42); + } + { + QContiguousCache contiguousCache; + contiguousCache.append(42); + } + { + QContiguousCache contiguousCache; + contiguousCache.prepend(42); + } +} + #include "tst_qcontiguouscache.moc" -- cgit v1.2.3