Mercurial > dedupe
view TestMemoryDBLink.cpp @ 78:9744ec195be3
Encapsulate EditDistance with caching.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Thu, 10 Oct 2013 01:07:52 +0200 |
| parents | 8136057988bc |
| children |
line wrap: on
line source
#include "MemoryDBLink.hpp" #include "Exception/ValueExistsException.hpp" #include "TestFramework.hpp" BOOST_AUTO_TEST_CASE( AddUpdateDeleteFile ) { MemoryDBLink link; QDateTime time1 = QDateTime::currentDateTime(); QDateTime time2 = time1.addSecs(1); BOOST_REQUIRE(!link.exists("test")); BOOST_REQUIRE_EQUAL(link.existsWithMtime("test", time1), FileDBLink::NONE); link.addFile("test", 1, time1, "a"); BOOST_REQUIRE_EQUAL(link.existsWithMtime("test", time1), FileDBLink::SAME); BOOST_REQUIRE(link.exists("test")); BOOST_REQUIRE_THROW(link.addFile("test", 1, time1, "a"), ValueExistsException); link.updateFile("test", 1, time2, "a"); BOOST_REQUIRE_EQUAL(link.existsWithMtime("test", time1), FileDBLink::MTIME_DIFFERENT); BOOST_REQUIRE(link.exists("test")); BOOST_REQUIRE_THROW(link.addFile("test", 1, time1, "a"), ValueExistsException); } BOOST_AUTO_TEST_CASE( SortUnsortable ) { MemoryDBLink link; QString path1 = "a"; int size1 = 1; QDateTime time1 = QDateTime::currentDateTime(); QByteArray checksum1 = QByteArray::fromHex("a"); QString path2 = "b"; int size2 = 2; QDateTime time2 = time1.addSecs(1); QByteArray checksum2 = QByteArray::fromHex("b"); link.addFile(path2, size2, time2, checksum2); link.addFile(path1, size1, time1, checksum1); { QList<FileDBLink::dbinf_ptr_t > out; out = link.sortOn("", FileDBLink::PATH, false); bool first = true; QString prev; foreach(FileDBLink::dbinf_ptr_t info, out) { if (first) { first = false; } else { BOOST_REQUIRE(prev <= info->path()); } prev = info->path(); } } }
