summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 2b2805d..242e424 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -38,13 +38,13 @@ private:
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 + std::to_string(i);
41 success = storage.read(keyPrefix + std::to_string(i), [&error, &reference](const std::string &value) { 41 success = storage.read(keyPrefix + std::to_string(i), [&keyMatch, &reference](const std::string &value) {
42 if (value != reference) { 42 if (value != reference) {
43 qDebug() << "Mismatch while reading"; 43 qDebug() << "Mismatch while reading";
44 keyMatch = false; 44 keyMatch = false;
45 } 45 }
46 }); 46 });
47 return succes && keyMatch; 47 return success && keyMatch;
48 } 48 }
49 49
50private Q_SLOTS: 50private Q_SLOTS:
@@ -56,11 +56,10 @@ private Q_SLOTS:
56 56
57 void cleanupTestCase() 57 void cleanupTestCase()
58 { 58 {
59 Database db(testDataPath, dbName); 59 Storage storage(testDataPath, dbName);
60 db.removeFromDisk(); 60 storage.removeFromDisk();
61 } 61 }
62 62
63
64 void testRead() 63 void testRead()
65 { 64 {
66 const int count = 100; 65 const int count = 100;
@@ -69,14 +68,14 @@ private Q_SLOTS:
69 68
70 //ensure we can read everything back correctly 69 //ensure we can read everything back correctly
71 { 70 {
72 Database db(testDataPath, dbName); 71 Storage storage(testDataPath, dbName);
73 for (int i = 0; i < count; i++) { 72 for (int i = 0; i < count; i++) {
74 QVERIFY(verify(db, i)); 73 QVERIFY(verify(storage, i));
75 } 74 }
76 } 75 }
77 76
78 Database db(testDataPath, dbName); 77 Storage storage(testDataPath, dbName);
79 db.removeFromDisk(); 78 storage.removeFromDisk();
80 } 79 }
81 80
82 void testConcurrentRead() 81 void testConcurrentRead()
@@ -90,9 +89,9 @@ private Q_SLOTS:
90 const int concurrencyLevel = 4; 89 const int concurrencyLevel = 4;
91 for (int num = 0; num < concurrencyLevel; num++) { 90 for (int num = 0; num < concurrencyLevel; num++) {
92 futures << QtConcurrent::run([this, count](){ 91 futures << QtConcurrent::run([this, count](){
93 Database db(testDataPath, dbName); 92 Storage storage(testDataPath, dbName);
94 for (int i = 0; i < count; i++) { 93 for (int i = 0; i < count; i++) {
95 if (!verify(db, i)) { 94 if (!verify(storage, i)) {
96 qWarning() << "invalid value"; 95 qWarning() << "invalid value";
97 break; 96 break;
98 } 97 }
@@ -103,8 +102,8 @@ private Q_SLOTS:
103 future.waitForFinished(); 102 future.waitForFinished();
104 } 103 }
105 104
106 Database db(testDataPath, dbName); 105 Storage storage(testDataPath, dbName);
107 db.removeFromDisk(); 106 storage.removeFromDisk();
108 } 107 }
109}; 108};
110 109