| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | #include "ProtocolDetector.h"#include "Exception.h"#include "util.h"#include <iostream>#include <cppunit/extensions/HelperMacros.h>namespace aria2 {class ProtocolDetectorTest:public CppUnit::TestFixture {  CPPUNIT_TEST_SUITE(ProtocolDetectorTest);  CPPUNIT_TEST(testIsStreamProtocol);  CPPUNIT_TEST(testGuessTorrentFile);  CPPUNIT_TEST(testGuessTorrentMagnet);  CPPUNIT_TEST(testGuessMetalinkFile);  CPPUNIT_TEST_SUITE_END();public:  void setUp() {}  void tearDown() {}  void testIsStreamProtocol();  void testGuessTorrentFile();  void testGuessTorrentMagnet();  void testGuessMetalinkFile();};CPPUNIT_TEST_SUITE_REGISTRATION(ProtocolDetectorTest);void ProtocolDetectorTest::testIsStreamProtocol(){  ProtocolDetector detector;  CPPUNIT_ASSERT(detector.isStreamProtocol("http://localhost/index.html"));  CPPUNIT_ASSERT(detector.isStreamProtocol("ftp://localhost/index.html"));  CPPUNIT_ASSERT(!detector.isStreamProtocol("/home/web/localhost/index.html"));}void ProtocolDetectorTest::testGuessTorrentFile(){  ProtocolDetector detector;  CPPUNIT_ASSERT(detector.guessTorrentFile("test.torrent"));  CPPUNIT_ASSERT(!detector.guessTorrentFile("http://localhost/test.torrent"));  CPPUNIT_ASSERT(!detector.guessTorrentFile("test.xml"));}void ProtocolDetectorTest::testGuessTorrentMagnet(){  ProtocolDetector detector;  CPPUNIT_ASSERT    (detector.guessTorrentMagnet     ("magnet:?xt=urn:btih:248d0a1cd08284299de78d5c1ed359bb46717d8c"));  CPPUNIT_ASSERT(!detector.guessTorrentMagnet("magnet:?"));}void ProtocolDetectorTest::testGuessMetalinkFile(){  ProtocolDetector detector;  CPPUNIT_ASSERT(detector.guessMetalinkFile("test.xml"));  CPPUNIT_ASSERT(!detector.guessMetalinkFile("http://localhost/test.xml"));  CPPUNIT_ASSERT(!detector.guessMetalinkFile("test.torrent"));}} // namespace aria2
 |