From d89c27c9a1cc4d2c4ea806d71653e32c2891077b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 20 Feb 2016 11:29:30 +0100 Subject: Get substring matches to work with sorted duplicates in store --- tests/indextest.cpp | 9 +++++++++ tests/storagetest.cpp | 15 +++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'tests') 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: [](const Index::Error &error){ qWarning() << "Error: "; }); QCOMPARE(values.size(), 0); } + { + QList values; + index.lookup(QByteArray("key"), [&values](const QByteArray &value) { + values << value; + }, + [](const Index::Error &error){ qWarning() << "Error: "; }, + true); + QCOMPARE(values.size(), 3); + } } }; 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: QCOMPARE(numValues, 2); } + void testFindSubstringKeysWithDuplicatesEnabled() + { + Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); + auto transaction = store.createTransaction(Sink::Storage::ReadWrite); + auto db = transaction.openDatabase("test", nullptr, true); + db.write("sub","value1"); + db.write("subsub","value2"); + db.write("wubsub","value3"); + int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { + return true; + }, nullptr, true); + + QCOMPARE(numValues, 2); + } + void testKeySorting() { Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); -- cgit v1.2.3