Add minor unittest for numeric id extraction #5933
authorChristian Kamm <mail@ckamm.de>
Tue, 5 Sep 2017 11:40:26 +0000 (13:40 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 5 Oct 2017 20:01:03 +0000 (22:01 +0200)
test/testsyncjournaldb.cpp

index 9e412aa85f2c76f028c3e0f72dc46ee76e9eda01..e01a32f131d8f4abc5bb3e34d1f8372b5c9ccfc4 100644 (file)
@@ -163,6 +163,19 @@ private slots:
         QVERIFY(!wipedRecord._valid);
     }
 
+    void testNumericId()
+    {
+        SyncJournalFileRecord record;
+
+        // Typical 8-digit padded id
+        record._fileId = "00000001abcd";
+        QCOMPARE(record.numericFileId(), QByteArray("00000001"));
+
+        // When the numeric id overflows the 8-digit boundary
+        record._fileId = "123456789ocidblaabcd";
+        QCOMPARE(record.numericFileId(), QByteArray("123456789"));
+    }
+
 private:
     SyncJournalDb _db;
 };