Mercurial > dedupe
comparison TestSqliteDBLink.cpp @ 2:2833b7f8884a
Sql backend is working.
Need to get more speed on comparisson.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Tue, 21 Aug 2012 14:25:33 +0200 |
| parents | |
| children | b5943e4bf676 |
comparison
equal
deleted
inserted
replaced
| 1:aae83c0a771d | 2:2833b7f8884a |
|---|---|
| 1 #include "SqliteDBLink.hpp" | |
| 2 #include "TestFramework.hpp" | |
| 3 | |
| 4 #include <QtCore/QDebug> | |
| 5 #include <QtCore/QTemporaryFile> | |
| 6 | |
| 7 BOOST_AUTO_TEST_CASE( TestSave ) | |
| 8 { | |
| 9 QDateTime now = QDateTime::currentDateTime(); | |
| 10 now = now.addSecs(-1000); | |
| 11 | |
| 12 QTemporaryFile sqlfile("XXXXXX.sqlite"); | |
| 13 sqlfile.open(); | |
| 14 | |
| 15 SqliteDBLink db(sqlfile.fileName()); | |
| 16 | |
| 17 QTemporaryFile testfile("XXXXXX.test"); | |
| 18 testfile.open(); | |
| 19 | |
| 20 db.addFile(testfile.fileName(), 4, now, "Sau"); | |
| 21 BOOST_REQUIRE(db.existsWithMtime(testfile.fileName(), now)); | |
| 22 { | |
| 23 const QList<QSharedPointer<FileDBLink::DBInfo> > values = db.values(); | |
| 24 BOOST_REQUIRE_EQUAL(values.size(), 1); | |
| 25 } | |
| 26 | |
| 27 now = now.addSecs(1); | |
| 28 | |
| 29 db.updateFile(testfile.fileName(), 4, now, "Jau"); | |
| 30 BOOST_REQUIRE(db.existsWithMtime(testfile.fileName(), now)); | |
| 31 { | |
| 32 const QList<QSharedPointer<FileDBLink::DBInfo> > values = db.values(); | |
| 33 BOOST_REQUIRE_EQUAL(values.size(), 1); | |
| 34 } | |
| 35 | |
| 36 testfile.write(QByteArray("test")); | |
| 37 testfile.close(); | |
| 38 | |
| 39 QFileInfo finf(testfile.fileName()); | |
| 40 | |
| 41 db.updateIfModified(testfile.fileName()); | |
| 42 { | |
| 43 const QList<QSharedPointer<FileDBLink::DBInfo> > values = db.values(); | |
| 44 BOOST_REQUIRE_EQUAL(values.size(), 1); | |
| 45 | |
| 46 QSharedPointer<FileDBLink::DBInfo> file = values[0]; | |
| 47 BOOST_REQUIRE_EQUAL(file->mtime(), finf.lastModified()); | |
| 48 } | |
| 49 } |
