2006-07-30 12:58:27 +00:00
|
|
|
#include "FeatureConfig.h"
|
2009-09-20 09:31:42 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-05-20 14:27:58 +00:00
|
|
|
#include "a2functional.h"
|
|
|
|
#include "array_fun.h"
|
2009-10-22 15:35:33 +00:00
|
|
|
#include "util.h"
|
2006-07-30 12:58:27 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2006-07-30 12:58:27 +00:00
|
|
|
class FeatureConfigTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(FeatureConfigTest);
|
|
|
|
CPPUNIT_TEST(testGetDefaultPort);
|
2012-09-22 09:54:14 +00:00
|
|
|
CPPUNIT_TEST(testStrSupportedFeature);
|
2008-04-27 05:55:02 +00:00
|
|
|
CPPUNIT_TEST(testFeatureSummary);
|
2006-07-30 12:58:27 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
public:
|
|
|
|
void testGetDefaultPort();
|
2012-09-22 09:54:14 +00:00
|
|
|
void testStrSupportedFeature();
|
2008-04-27 05:55:02 +00:00
|
|
|
void testFeatureSummary();
|
2006-07-30 12:58:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(FeatureConfigTest);
|
|
|
|
|
|
|
|
void FeatureConfigTest::testGetDefaultPort() {
|
2012-09-22 09:54:14 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)80, getDefaultPort("http"));
|
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)443, getDefaultPort("https"));
|
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)21, getDefaultPort("ftp"));
|
2015-05-11 15:52:50 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL((uint16_t)22, getDefaultPort("sftp"));
|
2006-07-30 12:58:27 +00:00
|
|
|
}
|
|
|
|
|
2012-09-22 09:54:14 +00:00
|
|
|
void FeatureConfigTest::testStrSupportedFeature() {
|
|
|
|
const char* https = strSupportedFeature(FEATURE_HTTPS);
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#ifdef ENABLE_SSL
|
2012-09-22 09:54:14 +00:00
|
|
|
CPPUNIT_ASSERT(https);
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#else
|
2012-09-22 09:54:14 +00:00
|
|
|
CPPUNIT_ASSERT(!https);
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#endif // ENABLE_SSL
|
2012-09-22 09:54:14 +00:00
|
|
|
CPPUNIT_ASSERT(!strSupportedFeature(MAX_FEATURE));
|
2015-05-11 15:52:50 +00:00
|
|
|
|
|
|
|
auto sftp = strSupportedFeature(FEATURE_SFTP);
|
|
|
|
#ifdef HAVE_LIBSSH2
|
|
|
|
CPPUNIT_ASSERT(sftp);
|
|
|
|
#else // !HAVE_LIBSSH2
|
|
|
|
CPPUNIT_ASSERT(!sftp);
|
|
|
|
#endif // !HAVE_LIBSSH2
|
2006-07-30 12:58:27 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 05:55:02 +00:00
|
|
|
void FeatureConfigTest::testFeatureSummary() {
|
2008-05-20 14:27:58 +00:00
|
|
|
const std::string features[] = {
|
|
|
|
|
2008-04-27 05:55:02 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
2008-05-20 14:27:58 +00:00
|
|
|
"Async DNS",
|
2008-04-27 05:55:02 +00:00
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2008-05-20 14:27:58 +00:00
|
|
|
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2008-05-20 14:27:58 +00:00
|
|
|
"BitTorrent",
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2008-05-20 14:27:58 +00:00
|
|
|
|
2008-09-05 15:34:04 +00:00
|
|
|
#ifdef HAVE_SQLITE3
|
|
|
|
"Firefox3 Cookie",
|
|
|
|
#endif // HAVE_SQLITE3
|
|
|
|
|
2011-02-18 13:34:38 +00:00
|
|
|
#ifdef HAVE_ZLIB
|
2008-07-22 16:05:02 +00:00
|
|
|
"GZip",
|
2011-02-18 13:34:38 +00:00
|
|
|
#endif // HAVE_ZLIB
|
2008-07-22 16:05:02 +00:00
|
|
|
|
2008-04-27 05:55:02 +00:00
|
|
|
#ifdef ENABLE_SSL
|
2008-05-20 14:27:58 +00:00
|
|
|
"HTTPS",
|
2008-04-27 05:55:02 +00:00
|
|
|
#endif // ENABLE_SSL
|
2008-05-20 14:27:58 +00:00
|
|
|
|
|
|
|
"Message Digest",
|
|
|
|
|
2008-04-27 05:55:02 +00:00
|
|
|
#ifdef ENABLE_METALINK
|
2008-05-20 14:27:58 +00:00
|
|
|
"Metalink",
|
2008-04-27 05:55:02 +00:00
|
|
|
#endif // ENABLE_METALINK
|
2008-05-20 14:27:58 +00:00
|
|
|
|
2009-09-20 09:31:42 +00:00
|
|
|
#ifdef ENABLE_XML_RPC
|
|
|
|
"XML-RPC",
|
|
|
|
#endif // ENABLE_XML_RPC
|
|
|
|
|
2015-05-11 15:52:50 +00:00
|
|
|
#ifdef HAVE_LIBSSH2
|
|
|
|
"SFTP",
|
|
|
|
#endif // HAVE_LIBSSH2
|
2008-05-20 14:27:58 +00:00
|
|
|
};
|
|
|
|
|
2013-06-24 12:46:42 +00:00
|
|
|
std::string featuresString = strjoin(std::begin(features),
|
|
|
|
std::end(features), ", ");
|
2012-09-22 09:54:14 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(featuresString, featureSummary());
|
2006-07-30 12:58:27 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|