diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hawd/dataset.cpp | 4 | ||||
-rw-r--r-- | tests/storagebenchmark.cpp | 10 | ||||
-rw-r--r-- | tests/storagetest.cpp | 20 |
3 files changed, 18 insertions, 16 deletions
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp index e1f9700..9f1d307 100644 --- a/tests/hawd/dataset.cpp +++ b/tests/hawd/dataset.cpp | |||
@@ -253,7 +253,7 @@ void Dataset::eachRow(const std::function<void(const Row &row)> &resultHandler) | |||
253 | } | 253 | } |
254 | 254 | ||
255 | Row row(*this); | 255 | Row row(*this); |
256 | m_storage.scan(nullptr, 0, | 256 | m_storage.scan("", |
257 | [&](void *key, int keySize, void *data, int dataSize) -> bool { | 257 | [&](void *key, int keySize, void *data, int dataSize) -> bool { |
258 | if (keySize != sizeof(qint64)) { | 258 | if (keySize != sizeof(qint64)) { |
259 | return true; | 259 | return true; |
@@ -277,7 +277,7 @@ Dataset::Row Dataset::row(qint64 key) | |||
277 | } | 277 | } |
278 | 278 | ||
279 | Row row(*this, key); | 279 | Row row(*this, key); |
280 | m_storage.scan((const char *)&key, sizeof(qint64), | 280 | m_storage.scan(QByteArray::fromRawData((const char *)&key, sizeof(qint64)), |
281 | [&row](void *keyPtr, int keyLength, void *valuePtr, int valueSize) -> bool { | 281 | [&row](void *keyPtr, int keyLength, void *valuePtr, int valueSize) -> bool { |
282 | QByteArray array((const char*)valuePtr, valueSize); | 282 | QByteArray array((const char*)valuePtr, valueSize); |
283 | row.fromBinary(array); | 283 | row.fromBinary(array); |
diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp index 9cf9a71..0233466 100644 --- a/tests/storagebenchmark.cpp +++ b/tests/storagebenchmark.cpp | |||
@@ -15,7 +15,7 @@ | |||
15 | using namespace Calendar; | 15 | using namespace Calendar; |
16 | using namespace flatbuffers; | 16 | using namespace flatbuffers; |
17 | 17 | ||
18 | static std::string createEvent() | 18 | static QByteArray createEvent() |
19 | { | 19 | { |
20 | static const size_t attachmentSize = 1024*2; // 2KB | 20 | static const size_t attachmentSize = 1024*2; // 2KB |
21 | static uint8_t rawData[attachmentSize]; | 21 | static uint8_t rawData[attachmentSize]; |
@@ -33,7 +33,7 @@ static std::string createEvent() | |||
33 | memcpy((void*)Calendar::GetEvent(fbb.GetBufferPointer())->attachment()->Data(), rawData, attachmentSize); | 33 | memcpy((void*)Calendar::GetEvent(fbb.GetBufferPointer())->attachment()->Data(), rawData, attachmentSize); |
34 | } | 34 | } |
35 | 35 | ||
36 | return std::string(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 36 | return QByteArray::fromRawData(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
37 | } | 37 | } |
38 | 38 | ||
39 | // static void readEvent(const std::string &data) | 39 | // static void readEvent(const std::string &data) |
@@ -103,9 +103,9 @@ private Q_SLOTS: | |||
103 | store->startTransaction(); | 103 | store->startTransaction(); |
104 | } | 104 | } |
105 | 105 | ||
106 | store->write(keyPrefix + std::to_string(i), event); | 106 | store->write(keyPrefix + QByteArray::number(i), event); |
107 | } else { | 107 | } else { |
108 | myfile << event; | 108 | myfile << event.toStdString(); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
@@ -122,7 +122,7 @@ private Q_SLOTS: | |||
122 | { | 122 | { |
123 | for (int i = 0; i < count; i++) { | 123 | for (int i = 0; i < count; i++) { |
124 | if (store) { | 124 | if (store) { |
125 | store->read(keyPrefix + std::to_string(i), [](std::string value) -> bool { return true; }); | 125 | store->scan(keyPrefix + QByteArray::number(i), [](const QByteArray &value) -> bool { return true; }); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
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 | } |