summaryrefslogtreecommitdiff
path: root/test/BittorrentHelperTest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-12-10 12:52:59 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-12-10 12:52:59 +0000
commit6c3a3fefa23689f640e71d474a7a132fc21f6e94 (patch)
tree692c9ba06f1ecabcb993d9b65d6a4abc5012a013 /test/BittorrentHelperTest.cc
parente80079c9b62c05c20b4d60fa70e05da4bf83d054 (diff)
2009-12-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Print Magnet URI in -S output. * src/AnnounceList.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * test/BittorrentHelperTest.cc
Diffstat (limited to 'test/BittorrentHelperTest.cc')
-rw-r--r--test/BittorrentHelperTest.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/BittorrentHelperTest.cc b/test/BittorrentHelperTest.cc
index a3d660a5..a2b9c3c5 100644
--- a/test/BittorrentHelperTest.cc
+++ b/test/BittorrentHelperTest.cc
@@ -62,6 +62,7 @@ class BittorrentHelperTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testParseMagnet);
CPPUNIT_TEST(testParseMagnet_base32);
CPPUNIT_TEST(testMetadata2Torrent);
+ CPPUNIT_TEST(testTorrent2Magnet);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
@@ -104,6 +105,7 @@ public:
void testParseMagnet();
void testParseMagnet_base32();
void testMetadata2Torrent();
+ void testTorrent2Magnet();
};
@@ -252,7 +254,7 @@ void BittorrentHelperTest::testGetAnnounceTier() {
const BDE& tier = announceList[0];
CPPUNIT_ASSERT_EQUAL((size_t)1, tier.size());
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/announce.php"),
- util::trim(tier[0].s()));
+ tier[0].s());
}
@@ -267,8 +269,7 @@ void BittorrentHelperTest::testGetAnnounceTierAnnounceList() {
const BDE& tier1 = announceList[0];
CPPUNIT_ASSERT_EQUAL((size_t)1, tier1.size());
- CPPUNIT_ASSERT_EQUAL(std::string("http://tracker1"),
- util::trim(tier1[0].s()));
+ CPPUNIT_ASSERT_EQUAL(std::string("http://tracker1"), tier1[0].s());
const BDE& tier2 = announceList[1];
CPPUNIT_ASSERT_EQUAL((size_t)1, tier2.size());
@@ -756,6 +757,20 @@ void BittorrentHelperTest::testMetadata2Torrent()
metadata2Torrent(metadata, attrs));
}
+void BittorrentHelperTest::testTorrent2Magnet()
+{
+ SharedHandle<DownloadContext> dctx(new DownloadContext());
+ load("test.torrent", dctx);
+
+ CPPUNIT_ASSERT_EQUAL
+ (std::string("magnet:?xt=urn:btih:248d0a1cd08284299de78d5c1ed359bb46717d8c"
+ "&dn=aria2-test"
+ "&tr=http%3A%2F%2Ftracker1"
+ "&tr=http%3A%2F%2Ftracker2"
+ "&tr=http%3A%2F%2Ftracker3"),
+ torrent2Magnet(dctx->getAttribute(BITTORRENT)));
+}
+
} // namespace bittorrent
} // namespace aria2