summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-09-25 14:30:48 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-07 17:26:45 (GMT)
commit9dba7627557364c3498809e775ab79bc6f0c3158 (patch)
tree640a093e29eb61824543dd9e82b3ae1765a00d5a /tests
parentbb00ac8d1251be3e703cc09e5fb2f100f24b398b (diff)
downloadQt-9dba7627557364c3498809e775ab79bc6f0c3158.zip
Qt-9dba7627557364c3498809e775ab79bc6f0c3158.tar.gz
Qt-9dba7627557364c3498809e775ab79bc6f0c3158.tar.bz2
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. Task-number: QTBUG-27339 Change-Id: Ib9acf5c0a9a826e6853e7beaf5e56511fde98dc6 (cherry-picked from qt5 commit 320c4e31e124f99601399d00935362b587c77510) Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp
index 437f140..a538a13 100644
--- a/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp
+++ b/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp
@@ -70,6 +70,7 @@ private slots:
void setCapacity();
void zeroCapacity();
+ void modifyZeroCapacityCache();
};
QTEST_MAIN(tst_QContiguousCache)
@@ -368,4 +369,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"