diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-31 15:07:12 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-31 15:07:12 +0200 |
commit | 4798de83c9f198bfc0a802a987c9002968fb6c2c (patch) | |
tree | 74412b79d0ca0c269ef2986d225a4eb71f6ec596 /tests/storagetest.cpp | |
parent | f90ca753a4b723dbf72996bbd1261dc786c7cce6 (diff) | |
download | sink-4798de83c9f198bfc0a802a987c9002968fb6c2c.tar.gz sink-4798de83c9f198bfc0a802a987c9002968fb6c2c.zip |
Fixed revision sorting
We used to sort wrong as soon as we got over revision 9.
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r-- | tests/storagetest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index 31809ce..ee6900d 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp | |||
@@ -436,6 +436,20 @@ private slots: | |||
436 | QCOMPARE(Sink::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); | 436 | QCOMPARE(Sink::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); |
437 | QCOMPARE(Sink::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); | 437 | QCOMPARE(Sink::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); |
438 | } | 438 | } |
439 | |||
440 | void testRecordRevisionSorting() | ||
441 | { | ||
442 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); | ||
443 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); | ||
444 | QByteArray result; | ||
445 | auto db = transaction.openDatabase("test", nullptr, false); | ||
446 | const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}"; | ||
447 | //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6) | ||
448 | db.write(Sink::Storage::assembleKey(uid, 6), "value1"); | ||
449 | db.write(Sink::Storage::assembleKey(uid, 10), "value2"); | ||
450 | db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; }); | ||
451 | QCOMPARE(result, QByteArray("value2")); | ||
452 | } | ||
439 | }; | 453 | }; |
440 | 454 | ||
441 | QTEST_MAIN(StorageTest) | 455 | QTEST_MAIN(StorageTest) |