diff options
Diffstat (limited to 'test/ServerStatManTest.cc')
| -rw-r--r-- | test/ServerStatManTest.cc | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/test/ServerStatManTest.cc b/test/ServerStatManTest.cc index dd5bab15..c0daef53 100644 --- a/test/ServerStatManTest.cc +++ b/test/ServerStatManTest.cc @@ -12,7 +12,7 @@ namespace aria2 { -class ServerStatManTest:public CppUnit::TestFixture { +class ServerStatManTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ServerStatManTest); CPPUNIT_TEST(testAddAndFind); @@ -20,6 +20,7 @@ class ServerStatManTest:public CppUnit::TestFixture { CPPUNIT_TEST(testLoad); CPPUNIT_TEST(testRemoveStaleServerStat); CPPUNIT_TEST_SUITE_END(); + public: void setUp() {} @@ -31,12 +32,12 @@ public: void testRemoveStaleServerStat(); }; - CPPUNIT_TEST_SUITE_REGISTRATION(ServerStatManTest); void ServerStatManTest::testAddAndFind() { - std::shared_ptr<ServerStat> localhost_http(new ServerStat("localhost", "http")); + std::shared_ptr<ServerStat> localhost_http( + new ServerStat("localhost", "http")); std::shared_ptr<ServerStat> localhost_ftp(new ServerStat("localhost", "ftp")); std::shared_ptr<ServerStat> mirror(new ServerStat("mirror", "http")); @@ -60,7 +61,8 @@ void ServerStatManTest::testAddAndFind() void ServerStatManTest::testSave() { - std::shared_ptr<ServerStat> localhost_http(new ServerStat("localhost", "http")); + std::shared_ptr<ServerStat> localhost_http( + new ServerStat("localhost", "http")); localhost_http->setDownloadSpeed(25000); localhost_http->setSingleConnectionAvgSpeed(100); localhost_http->setMultiConnectionAvgSpeed(101); @@ -79,43 +81,44 @@ void ServerStatManTest::testSave() CPPUNIT_ASSERT(ssm.add(localhost_ftp)); CPPUNIT_ASSERT(ssm.add(mirror)); - const char* filename = A2_TEST_OUT_DIR"/aria2_ServerStatManTest_testSave"; + const char* filename = A2_TEST_OUT_DIR "/aria2_ServerStatManTest_testSave"; CPPUNIT_ASSERT(ssm.save(filename)); - CPPUNIT_ASSERT_EQUAL - (std::string - ("host=localhost, protocol=ftp," - " dl_speed=30000," - " sc_avg_speed=0," - " mc_avg_speed=0," - " last_updated=1210000001," - " counter=0," - " status=OK\n" - - "host=localhost, protocol=http," - " dl_speed=25000," - " sc_avg_speed=100," - " mc_avg_speed=101," - " last_updated=1210000000," - " counter=5," - " status=OK\n" - - "host=mirror, protocol=http," - " dl_speed=0," - " sc_avg_speed=0," - " mc_avg_speed=0," - " last_updated=1210000002," - " counter=0," - " status=ERROR\n"), - readFile(filename)); + CPPUNIT_ASSERT_EQUAL(std::string("host=localhost, protocol=ftp," + " dl_speed=30000," + " sc_avg_speed=0," + " mc_avg_speed=0," + " last_updated=1210000001," + " counter=0," + " status=OK\n" + + "host=localhost, protocol=http," + " dl_speed=25000," + " sc_avg_speed=100," + " mc_avg_speed=101," + " last_updated=1210000000," + " counter=5," + " status=OK\n" + + "host=mirror, protocol=http," + " dl_speed=0," + " sc_avg_speed=0," + " mc_avg_speed=0," + " last_updated=1210000002," + " counter=0," + " status=ERROR\n"), + readFile(filename)); } void ServerStatManTest::testLoad() { - const char* filename = A2_TEST_OUT_DIR"/aria2_ServerStatManTest_testLoad"; + const char* filename = A2_TEST_OUT_DIR "/aria2_ServerStatManTest_testLoad"; std::string in = - "host=localhost, protocol=ftp, dl_speed=30000, last_updated=1210000001, status=OK\n" - "host=localhost, protocol=http, dl_speed=25000, sc_avg_speed=101, mc_avg_speed=102, last_updated=1210000000, counter=6, status=OK\n" - "host=mirror, protocol=http, dl_speed=0, last_updated=1210000002, status=ERROR\n"; + "host=localhost, protocol=ftp, dl_speed=30000, last_updated=1210000001, " + "status=OK\n" + "host=localhost, protocol=http, dl_speed=25000, sc_avg_speed=101, " + "mc_avg_speed=102, last_updated=1210000000, counter=6, status=OK\n" + "host=mirror, protocol=http, dl_speed=0, last_updated=1210000002, " + "status=ERROR\n"; BufferedFile fp(filename, BufferedFile::WRITE); CPPUNIT_ASSERT_EQUAL((size_t)in.size(), fp.write(in.data(), in.size())); CPPUNIT_ASSERT(fp.close() != EOF); @@ -143,7 +146,8 @@ void ServerStatManTest::testLoad() void ServerStatManTest::testRemoveStaleServerStat() { Time now; - std::shared_ptr<ServerStat> localhost_http(new ServerStat("localhost", "http")); + std::shared_ptr<ServerStat> localhost_http( + new ServerStat("localhost", "http")); localhost_http->setDownloadSpeed(25000); localhost_http->setLastUpdated(now); std::shared_ptr<ServerStat> localhost_ftp(new ServerStat("localhost", "ftp")); |
