diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-20 11:29:30 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-20 11:29:30 +0100 |
commit | d89c27c9a1cc4d2c4ea806d71653e32c2891077b (patch) | |
tree | 1bae2be5286e281c946b425b05346f7966c4cc6e /tests | |
parent | a4cf8be92253d1696a8907da85b1b6a8f5d4ad05 (diff) | |
download | sink-d89c27c9a1cc4d2c4ea806d71653e32c2891077b.tar.gz sink-d89c27c9a1cc4d2c4ea806d71653e32c2891077b.zip |
Get substring matches to work with sorted duplicates in store
Diffstat (limited to 'tests')
-rw-r--r-- | tests/indextest.cpp | 9 | ||||
-rw-r--r-- | tests/storagetest.cpp | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/indextest.cpp b/tests/indextest.cpp index ce1fde7..1676ecb 100644 --- a/tests/indextest.cpp +++ b/tests/indextest.cpp | |||
@@ -58,6 +58,15 @@ private slots: | |||
58 | [](const Index::Error &error){ qWarning() << "Error: "; }); | 58 | [](const Index::Error &error){ qWarning() << "Error: "; }); |
59 | QCOMPARE(values.size(), 0); | 59 | QCOMPARE(values.size(), 0); |
60 | } | 60 | } |
61 | { | ||
62 | QList<QByteArray> values; | ||
63 | index.lookup(QByteArray("key"), [&values](const QByteArray &value) { | ||
64 | values << value; | ||
65 | }, | ||
66 | [](const Index::Error &error){ qWarning() << "Error: "; }, | ||
67 | true); | ||
68 | QCOMPARE(values.size(), 3); | ||
69 | } | ||
61 | } | 70 | } |
62 | }; | 71 | }; |
63 | 72 | ||
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index 6341808..ebd9b8f 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp | |||
@@ -334,6 +334,21 @@ private slots: | |||
334 | QCOMPARE(numValues, 2); | 334 | QCOMPARE(numValues, 2); |
335 | } | 335 | } |
336 | 336 | ||
337 | void testFindSubstringKeysWithDuplicatesEnabled() | ||
338 | { | ||
339 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); | ||
340 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); | ||
341 | auto db = transaction.openDatabase("test", nullptr, true); | ||
342 | db.write("sub","value1"); | ||
343 | db.write("subsub","value2"); | ||
344 | db.write("wubsub","value3"); | ||
345 | int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { | ||
346 | return true; | ||
347 | }, nullptr, true); | ||
348 | |||
349 | QCOMPARE(numValues, 2); | ||
350 | } | ||
351 | |||
337 | void testKeySorting() | 352 | void testKeySorting() |
338 | { | 353 | { |
339 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); | 354 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |