[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdelibs/KDE/4.8] kdecore/tests: make the test fail reproducibly
From: Ralf Jung <ralfjung-e () gmx ! de>
Date: 2012-02-22 12:06:15
Message-ID: 20120222120615.E9E1DA60A6 () git ! kde ! org
[Download RAW message or body]
Git commit 4dae62abbd16befc90ee4f7ba005e3d218b58929 by Ralf Jung.
Committed on 22/02/2012 at 13:05.
Pushed by ralfjung into branch 'KDE/4.8'.
make the test fail reproducibly
M +18 -5 kdecore/tests/kshareddatacachetest.cpp
http://commits.kde.org/kdelibs/4dae62abbd16befc90ee4f7ba005e3d218b58929
diff --git a/kdecore/tests/kshareddatacachetest.cpp b/kdecore/tests/kshareddatacachetest.cpp
index 234f2f3..116cb1c 100644
--- a/kdecore/tests/kshareddatacachetest.cpp
+++ b/kdecore/tests/kshareddatacachetest.cpp
@@ -26,6 +26,7 @@
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QDir>
+#include <kstandarddirs.h>
#include <string.h> // strcpy
class KSharedDataCacheTest : public QObject
@@ -43,19 +44,31 @@ void KSharedDataCacheTest::initTestCase()
void KSharedDataCacheTest::simpleInsert()
{
- KSharedDataCache cache("myCache", 5*1024*1024);
+ const QLatin1String cacheName("myTestCache");
+ const QLatin1String key("mypic");
+ // clear the cache
+ QString cacheFile = KGlobal::dirs()->locateLocal("cache", cacheName + QLatin1String(".kcache"));
+ QFile file(cacheFile);
+ if (file.exists())
+ QVERIFY(file.remove());
+ // insert something into it
+ KSharedDataCache cache(cacheName, 5*1024*1024);
+ QVERIFY(file.exists()); // make sure we got the cache filename right
QByteArray data;
data.resize(9228);
strcpy(data.data(), "Hello world");
- const QString key = "mypic";
QVERIFY(cache.insert(key, data));
-
+ // read it out again
QByteArray result;
QVERIFY(cache.find(key, &result));
-#if 0
+ QCOMPARE(result, data);
+ // another insert
+ strcpy(data.data(), "Hello KDE");
+ QVERIFY(cache.insert(key, data));
+ // and another read
+ QVERIFY(cache.find(key, &result));
QEXPECT_FAIL("", "Bug in findNamedEntry!", Continue);
QCOMPARE(result, data);
-#endif
}
QTEST_KDEMAIN_CORE(KSharedDataCacheTest)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic