summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 1974355..b3313c0 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -82,6 +82,44 @@ private Q_SLOTS:
82 storage.removeFromDisk(); 82 storage.removeFromDisk();
83 } 83 }
84 84
85 void testScan()
86 {
87 const int count = 100;
88 populate(count);
89
90 //ensure we can scan for values
91 {
92 int hit = 0;
93 Storage store(testDataPath, dbName);
94 store.scan("", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
95 if (std::string(static_cast<char*>(keyValue), keySize) == "key50") {
96 hit++;
97 }
98 return true;
99 });
100 QCOMPARE(hit, 1);
101 }
102
103 //ensure we can read a single value
104 {
105 int hit = 0;
106 bool foundInvalidValue = false;
107 Storage store(testDataPath, dbName);
108 store.scan("key50", [&](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {
109 if (std::string(static_cast<char*>(keyValue), keySize) != "key50") {
110 foundInvalidValue = true;
111 }
112 hit++;
113 return true;
114 });
115 QVERIFY(!foundInvalidValue);
116 QCOMPARE(hit, 1);
117 }
118
119 Storage storage(testDataPath, dbName);
120 storage.removeFromDisk();
121 }
122
85 void testConcurrentRead() 123 void testConcurrentRead()
86 { 124 {
87 const int count = 10000; 125 const int count = 10000;