Mercurial > dedupe
diff TestFileDBLink.cpp @ 76:8136057988bc
Fixes to automatic report generating system.
A lot of new unittests.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Sat, 16 Feb 2013 15:32:20 +0100 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TestFileDBLink.cpp Sat Feb 16 15:32:20 2013 +0100 @@ -0,0 +1,60 @@ +#include "FileDBLink.hpp" +#include "TestFramework.hpp" + +BOOST_AUTO_TEST_CASE( DBInfoSerialize ) +{ + QString dir("de"); + QString name("cd"); + QString path(QString("%1/%2").arg(dir).arg(name)); + int size = 64; + QDateTime time1 = QDateTime::currentDateTime(); + QByteArray hash = QByteArray::fromHex("ab"); + FileDBLink::DBInfo info(path, size, time1, hash); + + BOOST_REQUIRE_EQUAL(info.path(), path); + BOOST_REQUIRE_EQUAL(info.name(), name); + BOOST_REQUIRE_EQUAL(info.size(), size); + BOOST_REQUIRE_EQUAL(info.mtime(), time1); + BOOST_REQUIRE_EQUAL(info.checksum(), hash); + + BOOST_REQUIRE_EQUAL(info.serialize(), + QString("%1, %2, %3, %4") + .arg(info.path()) + .arg(size) + .arg(time1.toString()) + .arg(QString(hash.toHex())) + ); +} + +BOOST_AUTO_TEST_CASE( ExtendedDBInfoSerialize ) +{ + QString dir("de"); + QString name("cd"); + QString path(QString("%1/%2").arg(dir).arg(name)); + int size = 64; + QDateTime time1 = QDateTime::currentDateTime(); + QByteArray hash = QByteArray::fromHex("ab"); + QString closestEditPath = "aa"; + int editDistance = 1; + FileDBLink::ExtendedDBInfo info(FileDBLink::DBInfo(path, size, time1, hash), + closestEditPath, + editDistance + ); + + BOOST_REQUIRE_EQUAL(info.path(), path); + BOOST_REQUIRE_EQUAL(info.name(), name); + BOOST_REQUIRE_EQUAL(info.size(), size); + BOOST_REQUIRE_EQUAL(info.mtime(), time1); + BOOST_REQUIRE_EQUAL(info.checksum(), hash); + BOOST_REQUIRE_EQUAL(info.editDistance(), editDistance); + + BOOST_REQUIRE_EQUAL(info.serialize(), + QString("%1, %2, %3, %4, %5, %6") + .arg(info.path()) + .arg(size) + .arg(time1.toString()) + .arg(QString(hash.toHex())) + .arg(closestEditPath) + .arg(editDistance) + ); +}
