summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-03-30 23:38:45 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-03-31 11:11:08 +0200
commit42f32ea5865c95028c577000e15e8a8631d16e74 (patch)
tree2d9e8a77ccccf088a8807f35f87e4264163d6cdd /tests/storagetest.cpp
parent34851314d39307f22df01a4b711e6fd3c5618e23 (diff)
downloadsink-42f32ea5865c95028c577000e15e8a8631d16e74.tar.gz
sink-42f32ea5865c95028c577000e15e8a8631d16e74.zip
Storage: API cleanup/use QByteArray instead of std::string
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 5b4a0ba..e339c87 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -28,7 +28,7 @@ private:
28 } 28 }
29 storage.startTransaction(); 29 storage.startTransaction();
30 } 30 }
31 storage.write(keyPrefix + std::to_string(i), keyPrefix + std::to_string(i)); 31 storage.write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i));
32 } 32 }
33 storage.commitTransaction(); 33 storage.commitTransaction();
34 } 34 }
@@ -37,9 +37,9 @@ private:
37 { 37 {
38 bool success = true; 38 bool success = true;
39 bool keyMatch = true; 39 bool keyMatch = true;
40 const auto reference = keyPrefix + std::to_string(i); 40 const auto reference = keyPrefix + QByteArray::number(i);
41 storage.read(keyPrefix + std::to_string(i), 41 storage.scan(keyPrefix + QByteArray::number(i),
42 [&keyMatch, &reference](const std::string &value) -> bool { 42 [&keyMatch, &reference](const QByteArray &value) -> bool {
43 if (value != reference) { 43 if (value != reference) {
44 qDebug() << "Mismatch while reading"; 44 qDebug() << "Mismatch while reading";
45 keyMatch = false; 45 keyMatch = false;
@@ -47,7 +47,7 @@ private:
47 return keyMatch; 47 return keyMatch;
48 }, 48 },
49 [&success](const Akonadi2::Storage::Error &error) { 49 [&success](const Akonadi2::Storage::Error &error) {
50 qDebug() << QString::fromStdString(error.message); 50 qDebug() << error.message;
51 success = false; 51 success = false;
52 } 52 }
53 ); 53 );
@@ -133,7 +133,7 @@ private Q_SLOTS:
133 populate(3); 133 populate(3);
134 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); 134 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite);
135 store.scan("key1", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 135 store.scan("key1", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
136 store.remove(keyValue, keySize, [](const Akonadi2::Storage::Error &) { 136 store.remove(QByteArray::fromRawData(static_cast<const char*>(keyValue), keySize), [](const Akonadi2::Storage::Error &) {
137 QVERIFY(false); 137 QVERIFY(false);
138 }); 138 });
139 return false; 139 return false;
@@ -144,14 +144,16 @@ private Q_SLOTS:
144 { 144 {
145 bool gotResult = false; 145 bool gotResult = false;
146 bool gotError = false; 146 bool gotError = false;
147 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadOnly); 147 Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite);
148 store.scan(0, 0, [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 148 int numValues = store.scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
149 gotResult = true; 149 gotResult = true;
150 return false; 150 return false;
151 }, 151 },
152 [&](Akonadi2::Storage::Error) { 152 [&](const Akonadi2::Storage::Error &error) {
153 qDebug() << error.message;
153 gotError = true; 154 gotError = true;
154 }); 155 });
156 QCOMPARE(numValues, 0);
155 QVERIFY(!gotResult); 157 QVERIFY(!gotResult);
156 QVERIFY(!gotError); 158 QVERIFY(!gotError);
157 } 159 }