summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-08-14 13:48:31 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-08-14 13:48:31 +0000
commit2f14fec78dfc96b88a905621d35f1d726df0791d (patch)
tree8eb4dc9cf94f021ccbdf77dca88924c2c9bf4cea /test
parent43dae4fd916bb35bf7fd8554fc86ce34c3e7a31b (diff)
parent7ca1b43eddd1aba1c71a38dfb46b5ac5685b43d0 (diff)
Tagging 0.7.0 release of aria2release-0.7.0
Diffstat (limited to 'test')
-rw-r--r--test/MetalinkEntryTest.cc33
-rw-r--r--test/UtilTest.cc4
-rw-r--r--test/Xml2MetalinkProcessorTest.cc12
3 files changed, 22 insertions, 27 deletions
diff --git a/test/MetalinkEntryTest.cc b/test/MetalinkEntryTest.cc
index 99b47fc2..2f924907 100644
--- a/test/MetalinkEntryTest.cc
+++ b/test/MetalinkEntryTest.cc
@@ -8,7 +8,6 @@ class MetalinkEntryTest:public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(MetalinkEntryTest);
CPPUNIT_TEST(testDropUnsupportedResource);
CPPUNIT_TEST(testReorderResourcesByPreference);
- CPPUNIT_TEST(testCheck);
CPPUNIT_TEST_SUITE_END();
private:
@@ -20,7 +19,6 @@ public:
void testDropUnsupportedResource();
void testReorderResourcesByPreference();
- void testCheck();
};
@@ -48,11 +46,17 @@ MetalinkEntry* createTestEntry() {
res4->type = MetalinkResource::TYPE_NOT_SUPPORTED;
res4->location = "ad";
res4->preference = 10;
+ MetalinkResource* res5 = new MetalinkResource();
+ res5->url = "https://myhost/aria2.tar.bz2";
+ res5->type = MetalinkResource::TYPE_HTTPS;
+ res5->location = "jp";
+ res5->preference = 90;
entry->resources.push_back(res1);
entry->resources.push_back(res2);
entry->resources.push_back(res3);
entry->resources.push_back(res4);
+ entry->resources.push_back(res5);
return entry;
}
@@ -61,12 +65,16 @@ void MetalinkEntryTest::testDropUnsupportedResource() {
entry->dropUnsupportedResource();
- CPPUNIT_ASSERT_EQUAL(2, (int)entry->resources.size());
+ CPPUNIT_ASSERT_EQUAL(4, (int)entry->resources.size());
CPPUNIT_ASSERT_EQUAL((int)MetalinkResource::TYPE_FTP,
entry->resources.at(0)->type);
CPPUNIT_ASSERT_EQUAL((int)MetalinkResource::TYPE_HTTP,
entry->resources.at(1)->type);
+ CPPUNIT_ASSERT_EQUAL((int)MetalinkResource::TYPE_BITTORRENT,
+ entry->resources.at(2)->type);
+ CPPUNIT_ASSERT_EQUAL((int)MetalinkResource::TYPE_HTTPS,
+ entry->resources.at(3)->type);
}
void MetalinkEntryTest::testReorderResourcesByPreference() {
@@ -75,19 +83,8 @@ void MetalinkEntryTest::testReorderResourcesByPreference() {
entry->reorderResourcesByPreference();
CPPUNIT_ASSERT_EQUAL(100, entry->resources.at(0)->preference);
- CPPUNIT_ASSERT_EQUAL(60, entry->resources.at(1)->preference);
- CPPUNIT_ASSERT_EQUAL(50, entry->resources.at(2)->preference);
- CPPUNIT_ASSERT_EQUAL(10, entry->resources.at(3)->preference);
-}
-
-void MetalinkEntryTest::testCheck() {
- MetalinkEntry entry;
- string filename = "4096chunk.txt";
- CPPUNIT_ASSERT(entry.check(filename));
- entry.md5 = "82a7348c2e03731109d0cf45a7325b88";
- CPPUNIT_ASSERT(entry.check(filename));
- entry.md5 = "00000000000000000000000000000000";
- CPPUNIT_ASSERT(!entry.check(filename));
- entry.sha1 = "608cabc0f2fa18c260cafd974516865c772363d5";
- CPPUNIT_ASSERT(entry.check(filename));
+ CPPUNIT_ASSERT_EQUAL(90, entry->resources.at(1)->preference);
+ CPPUNIT_ASSERT_EQUAL(60, entry->resources.at(2)->preference);
+ CPPUNIT_ASSERT_EQUAL(50, entry->resources.at(3)->preference);
+ CPPUNIT_ASSERT_EQUAL(10, entry->resources.at(4)->preference);
}
diff --git a/test/UtilTest.cc b/test/UtilTest.cc
index 150c8f68..a7255f8f 100644
--- a/test/UtilTest.cc
+++ b/test/UtilTest.cc
@@ -224,12 +224,12 @@ void UtilTest::testRandomAlpha() {
void UtilTest::testFileChecksum() {
unsigned char buf[20];
string filename = "4096chunk.txt";
- Util::fileChecksum(filename, buf, MessageDigestContext::ALGO_SHA1);
+ Util::fileChecksum(filename, buf, DIGEST_ALGO_SHA1);
string sha1 = Util::toHex(buf, 20);
CPPUNIT_ASSERT_EQUAL(string("608cabc0f2fa18c260cafd974516865c772363d5"),
sha1);
- Util::fileChecksum(filename, buf, MessageDigestContext::ALGO_MD5);
+ Util::fileChecksum(filename, buf, DIGEST_ALGO_MD5);
string md5 = Util::toHex(buf, 16);
CPPUNIT_ASSERT_EQUAL(string("82a7348c2e03731109d0cf45a7325b88"),
md5);
diff --git a/test/Xml2MetalinkProcessorTest.cc b/test/Xml2MetalinkProcessorTest.cc
index 3886f90e..8669bc8a 100644
--- a/test/Xml2MetalinkProcessorTest.cc
+++ b/test/Xml2MetalinkProcessorTest.cc
@@ -33,11 +33,10 @@ void Xml2MetalinkProcessorTest::testParseFile() {
CPPUNIT_ASSERT_EQUAL(string("0.5.2"), entry1->version);
CPPUNIT_ASSERT_EQUAL(string("en-US"), entry1->language);
CPPUNIT_ASSERT_EQUAL(string("Linux-x86"), entry1->os);
- CPPUNIT_ASSERT_EQUAL(string("fc4d834e89c18c99b2615d902750948c"),
- entry1->md5);
CPPUNIT_ASSERT_EQUAL(string("a96cf3f0266b91d87d5124cf94326422800b627d"),
- entry1->sha1);
-
+ entry1->checksum.getMessageDigest());
+ CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry1->checksum.getDigestAlgo());
+
MetalinkResources::iterator resourceItr1 = entry1->resources.begin();
MetalinkResource* resource1 = *resourceItr1;
CPPUNIT_ASSERT_EQUAL((int)MetalinkResource::TYPE_FTP, resource1->type);
@@ -57,10 +56,9 @@ void Xml2MetalinkProcessorTest::testParseFile() {
CPPUNIT_ASSERT_EQUAL(string("0.5.1"), entry2->version);
CPPUNIT_ASSERT_EQUAL(string("ja-JP"), entry2->language);
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
- CPPUNIT_ASSERT_EQUAL(string("92296e19c406d77d21bda0bb944eac46"),
- entry2->md5);
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
- entry2->sha1);
+ entry2->checksum.getMessageDigest());
+ CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum.getDigestAlgo());
delete metalinker;
}