summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2014-12-15 19:28:05 +0100
committerAaron Seigo <aseigo@kde.org>2014-12-15 19:28:05 +0100
commit3dd90236e7927028ff5c98635f8075189c9869c2 (patch)
treeaefb7ce4e698b6c9d6993546d5e437a61d7ce4e3 /tests/storagetest.cpp
parentcb0f5fb769380db5771ff8e0dba8d780cdc92edb (diff)
downloadsink-3dd90236e7927028ff5c98635f8075189c9869c2.tar.gz
sink-3dd90236e7927028ff5c98635f8075189c9869c2.zip
namespace everything in libs with Akonadi2
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 3c20135..a771042 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -19,7 +19,7 @@ private:
19 19
20 void populate(int count) 20 void populate(int count)
21 { 21 {
22 Storage storage(testDataPath, dbName, Storage::ReadWrite); 22 Akonadi2::Storage storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite);
23 for (int i = 0; i < count; i++) { 23 for (int i = 0; i < count; i++) {
24 //This should perhaps become an implementation detail of the db? 24 //This should perhaps become an implementation detail of the db?
25 if (i % 10000 == 0) { 25 if (i % 10000 == 0) {
@@ -33,7 +33,7 @@ private:
33 storage.commitTransaction(); 33 storage.commitTransaction();
34 } 34 }
35 35
36 bool verify(Storage &storage, int i) 36 bool verify(Akonadi2::Storage &storage, int i)
37 { 37 {
38 bool success = true; 38 bool success = true;
39 bool keyMatch = true; 39 bool keyMatch = true;
@@ -46,7 +46,7 @@ private:
46 } 46 }
47 return keyMatch; 47 return keyMatch;
48 }, 48 },
49 [&success](const Storage::Error &) { success = false; } 49 [&success](const Akonadi2::Storage::Error &) { success = false; }
50 ); 50 );
51 return success && keyMatch; 51 return success && keyMatch;
52 } 52 }
@@ -60,7 +60,7 @@ private Q_SLOTS:
60 60
61 void cleanupTestCase() 61 void cleanupTestCase()
62 { 62 {
63 Storage storage(testDataPath, dbName); 63 Akonadi2::Storage storage(testDataPath, dbName);
64 storage.removeFromDisk(); 64 storage.removeFromDisk();
65 } 65 }
66 66
@@ -72,13 +72,13 @@ private Q_SLOTS:
72 72
73 //ensure we can read everything back correctly 73 //ensure we can read everything back correctly
74 { 74 {
75 Storage storage(testDataPath, dbName); 75 Akonadi2::Storage storage(testDataPath, dbName);
76 for (int i = 0; i < count; i++) { 76 for (int i = 0; i < count; i++) {
77 QVERIFY(verify(storage, i)); 77 QVERIFY(verify(storage, i));
78 } 78 }
79 } 79 }
80 80
81 Storage storage(testDataPath, dbName); 81 Akonadi2::Storage storage(testDataPath, dbName);
82 storage.removeFromDisk(); 82 storage.removeFromDisk();
83 } 83 }
84 84
@@ -90,7 +90,7 @@ private Q_SLOTS:
90 //ensure we can scan for values 90 //ensure we can scan for values
91 { 91 {
92 int hit = 0; 92 int hit = 0;
93 Storage store(testDataPath, dbName); 93 Akonadi2::Storage store(testDataPath, dbName);
94 store.scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 94 store.scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
95 if (std::string(static_cast<char*>(keyValue), keySize) == "key50") { 95 if (std::string(static_cast<char*>(keyValue), keySize) == "key50") {
96 hit++; 96 hit++;
@@ -104,7 +104,7 @@ private Q_SLOTS:
104 { 104 {
105 int hit = 0; 105 int hit = 0;
106 bool foundInvalidValue = false; 106 bool foundInvalidValue = false;
107 Storage store(testDataPath, dbName); 107 Akonadi2::Storage store(testDataPath, dbName);
108 store.scan("key50", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 108 store.scan("key50", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
109 if (std::string(static_cast<char*>(keyValue), keySize) != "key50") { 109 if (std::string(static_cast<char*>(keyValue), keySize) != "key50") {
110 foundInvalidValue = true; 110 foundInvalidValue = true;
@@ -116,7 +116,7 @@ private Q_SLOTS:
116 QCOMPARE(hit, 1); 116 QCOMPARE(hit, 1);
117 } 117 }
118 118
119 Storage storage(testDataPath, dbName); 119 Akonadi2::Storage storage(testDataPath, dbName);
120 storage.removeFromDisk(); 120 storage.removeFromDisk();
121 } 121 }
122 122
@@ -132,7 +132,7 @@ private Q_SLOTS:
132 const int concurrencyLevel = 10; 132 const int concurrencyLevel = 10;
133 for (int num = 0; num < concurrencyLevel; num++) { 133 for (int num = 0; num < concurrencyLevel; num++) {
134 futures << QtConcurrent::run([this, count, &error](){ 134 futures << QtConcurrent::run([this, count, &error](){
135 Storage storage(testDataPath, dbName); 135 Akonadi2::Storage storage(testDataPath, dbName);
136 for (int i = 0; i < count; i++) { 136 for (int i = 0; i < count; i++) {
137 if (!verify(storage, i)) { 137 if (!verify(storage, i)) {
138 error = true; 138 error = true;
@@ -146,7 +146,7 @@ private Q_SLOTS:
146 } 146 }
147 QVERIFY(!error); 147 QVERIFY(!error);
148 148
149 Storage storage(testDataPath, dbName); 149 Akonadi2::Storage storage(testDataPath, dbName);
150 storage.removeFromDisk(); 150 storage.removeFromDisk();
151 } 151 }
152}; 152};