summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-09-25 16:30:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-19 07:50:29 +0200
commit320c4e31e124f99601399d00935362b587c77510 (patch)
treec2f66d1e11284fc7e9167d6a1cdf241da4500b60 /tests/auto/corelib
parentc4b2d77f40a42a67480bb49aa63b0953c80c024a (diff)
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 <giuseppe.dangelo@kdab.com> Reviewed-by: Ian Walters <ian@walters.id.au> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp21
1 files changed, 21 insertions, 0 deletions
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<int> contiguousCache;
+ contiguousCache.insert(0, 42);
+ }
+ {
+ QContiguousCache<int> contiguousCache;
+ contiguousCache.insert(1, 42);
+ }
+ {
+ QContiguousCache<int> contiguousCache;
+ contiguousCache.append(42);
+ }
+ {
+ QContiguousCache<int> contiguousCache;
+ contiguousCache.prepend(42);
+ }
+}
+
#include "tst_qcontiguouscache.moc"