diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:39:47 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:40:08 +0900 |
| commit | b1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch) | |
| tree | 9ce465b42bf09372118335c7c619bb2b41869eaf /test/SessionSerializerTest.cc | |
| parent | 4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff) | |
make clang-format using clang-format-3.6
Diffstat (limited to 'test/SessionSerializerTest.cc')
| -rw-r--r-- | test/SessionSerializerTest.cc | 69 |
1 files changed, 32 insertions, 37 deletions
diff --git a/test/SessionSerializerTest.cc b/test/SessionSerializerTest.cc index 9d996d4c..432321b1 100644 --- a/test/SessionSerializerTest.cc +++ b/test/SessionSerializerTest.cc @@ -18,30 +18,28 @@ namespace aria2 { -class SessionSerializerTest:public CppUnit::TestFixture { +class SessionSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(SessionSerializerTest); CPPUNIT_TEST(testSave); CPPUNIT_TEST(testSaveErrorDownload); CPPUNIT_TEST_SUITE_END(); + public: void testSave(); void testSaveErrorDownload(); }; - CPPUNIT_TEST_SUITE_REGISTRATION(SessionSerializerTest); void SessionSerializerTest::testSave() { #if defined(ENABLE_BITTORRENT) && defined(ENABLE_METALINK) - std::vector<std::string> uris { - "http://localhost/file", - "http://mirror/file", - A2_TEST_DIR"/test.torrent", - A2_TEST_DIR"/serialize_session.meta4", - "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C"}; - std::vector<std::shared_ptr<RequestGroup> > result; + std::vector<std::string> uris{ + "http://localhost/file", "http://mirror/file", + A2_TEST_DIR "/test.torrent", A2_TEST_DIR "/serialize_session.meta4", + "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C"}; + std::vector<std::shared_ptr<RequestGroup>> result; std::shared_ptr<Option> option(new Option()); option->put(PREF_DIR, "/tmp"); createRequestGroupForUri(result, option, uris); @@ -51,12 +49,11 @@ void SessionSerializerTest::testSave() RequestGroupMan rgman{result, 1, option.get()}; SessionSerializer s(&rgman); std::shared_ptr<DownloadResult> drs[] = { - // REMOVED downloads will not be saved. - createDownloadResult(error_code::REMOVED, "http://removed"), - createDownloadResult(error_code::TIME_OUT, "http://error"), - createDownloadResult(error_code::FINISHED, "http://finished"), - createDownloadResult(error_code::FINISHED, "http://force-save") - }; + // REMOVED downloads will not be saved. + createDownloadResult(error_code::REMOVED, "http://removed"), + createDownloadResult(error_code::TIME_OUT, "http://error"), + createDownloadResult(error_code::FINISHED, "http://finished"), + createDownloadResult(error_code::FINISHED, "http://force-save")}; // This URI will be discarded because same URI exists in remaining // URIs. drs[1]->fileEntries[0]->getRemainingUris().push_back("http://error"); @@ -74,7 +71,7 @@ void SessionSerializerTest::testSave() 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) { + for (size_t i = 0; i < sizeof(drs) / sizeof(drs[0]); ++i) { rgman.addDownloadResult(drs[i]); } @@ -83,12 +80,14 @@ void SessionSerializerTest::testSave() rgman.fillRequestGroupFromReserver(&e); CPPUNIT_ASSERT_EQUAL((size_t)1, rgman.getRequestGroups().size()); - std::string filename = A2_TEST_OUT_DIR"/aria2_SessionSerializerTest_testSave"; + std::string filename = + A2_TEST_OUT_DIR "/aria2_SessionSerializerTest_testSave"; s.save(filename); std::ifstream ss(filename.c_str(), std::ios::binary); std::string line; std::getline(ss, line); - CPPUNIT_ASSERT_EQUAL(std::string("http://error\thttp://error3\thttp://error2\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); @@ -100,36 +99,32 @@ void SessionSerializerTest::testSave() CPPUNIT_ASSERT_EQUAL(std::string(" force-save=true"), line); // Check active download is also saved std::getline(ss, line); - CPPUNIT_ASSERT_EQUAL(uris[0]+"\t"+uris[1]+"\t", line); + CPPUNIT_ASSERT_EQUAL(uris[0] + "\t" + uris[1] + "\t", line); std::getline(ss, line); - CPPUNIT_ASSERT_EQUAL(fmt(" gid=%s", - GroupId::toHex(result[0]->getGID()).c_str()), - line); + CPPUNIT_ASSERT_EQUAL( + fmt(" gid=%s", GroupId::toHex(result[0]->getGID()).c_str()), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(uris[2], line); std::getline(ss, line); - CPPUNIT_ASSERT_EQUAL(fmt(" gid=%s", - GroupId::toHex(result[1]->getGID()).c_str()), - line); + CPPUNIT_ASSERT_EQUAL( + fmt(" gid=%s", GroupId::toHex(result[1]->getGID()).c_str()), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(uris[3], line); std::getline(ss, line); // local metalink download does not save meaningful GID - CPPUNIT_ASSERT(fmt(" gid=%s", - GroupId::toHex(result[2]->getGID()).c_str()) - != line); + CPPUNIT_ASSERT(fmt(" gid=%s", GroupId::toHex(result[2]->getGID()).c_str()) != + line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(uris[4], line); std::getline(ss, line); - CPPUNIT_ASSERT_EQUAL(fmt(" gid=%s", - GroupId::toHex(result[4]->getGID()).c_str()), - line); + CPPUNIT_ASSERT_EQUAL( + fmt(" gid=%s", GroupId::toHex(result[4]->getGID()).c_str()), line); std::getline(ss, line); CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line); std::getline(ss, line); @@ -141,18 +136,18 @@ void SessionSerializerTest::testSave() void SessionSerializerTest::testSaveErrorDownload() { - std::shared_ptr<DownloadResult> dr = createDownloadResult(error_code::TIME_OUT, - "http://error"); - dr->fileEntries[0]->getSpentUris().swap - (dr->fileEntries[0]->getRemainingUris()); + std::shared_ptr<DownloadResult> dr = + createDownloadResult(error_code::TIME_OUT, "http://error"); + dr->fileEntries[0]->getSpentUris().swap( + dr->fileEntries[0]->getRemainingUris()); std::shared_ptr<Option> option(new Option()); option->put(PREF_MAX_DOWNLOAD_RESULT, "10"); - RequestGroupMan rgman{std::vector<std::shared_ptr<RequestGroup> >(), 1, + RequestGroupMan rgman{std::vector<std::shared_ptr<RequestGroup>>(), 1, option.get()}; rgman.addDownloadResult(dr); SessionSerializer s(&rgman); std::string filename = - A2_TEST_OUT_DIR"/aria2_SessionSerializerTest_testSaveErrorDownload"; + A2_TEST_OUT_DIR "/aria2_SessionSerializerTest_testSaveErrorDownload"; CPPUNIT_ASSERT(s.save(filename)); std::ifstream ss(filename.c_str(), std::ios::binary); std::string line; |
