diff options
| author | Nils Maier <maierman@web.de> | 2013-04-28 20:59:22 +0200 |
|---|---|---|
| committer | Nils Maier <maierman@web.de> | 2013-06-10 00:58:28 +0200 |
| commit | 3b32dcb9f1dc9706b6a74b46e8ebc147e5844616 (patch) | |
| tree | d1a0a677f3a8bff389e01db9c1cf1f7d994f816c /test/SessionSerializerTest.cc | |
| parent | ca7c63aa7ed91d32cc912dfcfbd8a3f5fcf22163 (diff) | |
SessionSerializer: Truly unique URIs
Before, only spent uris where sanitized not to be contained within
remaining uris. Change this so that each uri in the
union(remaining,spent) get saved once at most.
The order of the uris will won't be changed, with remaining uris going
first followed by spent uris.
Also avoid copying the uri std::strings around during dupe checking,
usually resulting in better performance regarding CPU and space.
Diffstat (limited to 'test/SessionSerializerTest.cc')
| -rw-r--r-- | test/SessionSerializerTest.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/SessionSerializerTest.cc b/test/SessionSerializerTest.cc index 9ebc6acd..b47a461a 100644 --- a/test/SessionSerializerTest.cc +++ b/test/SessionSerializerTest.cc @@ -61,8 +61,19 @@ void SessionSerializerTest::testSave() }; // This URI will be discarded because same URI exists in remaining // URIs. + drs[1]->fileEntries[0]->getRemainingUris().push_back("http://error"); + drs[1]->fileEntries[0]->getRemainingUris().push_back("http://error3"); + // This URI will be discarded because same URI exists in remaining + // URIs. + drs[1]->fileEntries[0]->getRemainingUris().push_back("http://error"); + // + // This URI will be discarded because same URI exists in remaining + // URIs. drs[1]->fileEntries[0]->getSpentUris().push_back("http://error"); drs[1]->fileEntries[0]->getSpentUris().push_back("http://error2"); + // This URI will be discarded because same URI exists in remaining + // URIs. + drs[1]->fileEntries[0]->getSpentUris().push_back("http://error"); drs[3]->option->put(PREF_FORCE_SAVE, A2_V_TRUE); for(size_t i = 0; i < sizeof(drs)/sizeof(drs[0]); ++i) { @@ -79,7 +90,7 @@ void SessionSerializerTest::testSave() std::ifstream ss(filename.c_str(), std::ios::binary); std::string line; std::getline(ss, line); - CPPUNIT_ASSERT_EQUAL(std::string("http://error2\thttp://error\t"), line); + CPPUNIT_ASSERT_EQUAL(std::string("http://error\thttp://error3\thttp://error2\t"), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(fmt(" gid=%s", drs[1]->gid->toHex().c_str()), line); std::getline(ss, line); |
