Mercurial > dedupe
diff TestMemoryDBLink.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 | c9447697609f |
| children | 9744ec195be3 |
line wrap: on
line diff
--- a/TestMemoryDBLink.cpp Sat Feb 16 15:30:12 2013 +0100 +++ b/TestMemoryDBLink.cpp Sat Feb 16 15:32:20 2013 +0100 @@ -6,33 +6,60 @@ { MemoryDBLink link; - QDateTime time1; + 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_REQUIRE(!map.find(k4)); - map.insert(k4); - BOOST_WARN_EQUAL(map.depth(), 2u); - BOOST_WARN_EQUAL(map.total_depth(), 8u); - BOOST_REQUIRE_EQUAL(map.size(), 4u); - BOOST_REQUIRE_EQUAL(map.optimal_depth(), 3u); - BOOST_REQUIRE_THROW(map.insert(k4), ValueExistsException); - BOOST_REQUIRE(map.find(k1)); - BOOST_REQUIRE_EQUAL(*map.find(k1), k1); - BOOST_REQUIRE(map.find(k2)); - BOOST_REQUIRE_EQUAL(*map.find(k2), k2); - BOOST_REQUIRE(map.find(k4)); - BOOST_REQUIRE_EQUAL(*map.find(k4), k4); - */ + } + +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(); + } + } + +}
