forked from aria2/aria2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeatureConfigTest.cc
99 lines (76 loc) · 2.06 KB
/
FeatureConfigTest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "FeatureConfig.h"
#include <algorithm>
#include <cppunit/extensions/HelperMacros.h>
#include "a2functional.h"
#include "array_fun.h"
#include "util.h"
namespace aria2 {
class FeatureConfigTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(FeatureConfigTest);
CPPUNIT_TEST(testGetDefaultPort);
CPPUNIT_TEST(testStrSupportedFeature);
CPPUNIT_TEST(testFeatureSummary);
CPPUNIT_TEST_SUITE_END();
public:
void testGetDefaultPort();
void testStrSupportedFeature();
void testFeatureSummary();
};
CPPUNIT_TEST_SUITE_REGISTRATION(FeatureConfigTest);
void FeatureConfigTest::testGetDefaultPort()
{
CPPUNIT_ASSERT_EQUAL((uint16_t)80, getDefaultPort("http"));
CPPUNIT_ASSERT_EQUAL((uint16_t)443, getDefaultPort("https"));
CPPUNIT_ASSERT_EQUAL((uint16_t)21, getDefaultPort("ftp"));
CPPUNIT_ASSERT_EQUAL((uint16_t)22, getDefaultPort("sftp"));
}
void FeatureConfigTest::testStrSupportedFeature()
{
const char* https = strSupportedFeature(FEATURE_HTTPS);
#ifdef ENABLE_SSL
CPPUNIT_ASSERT(https);
#else
CPPUNIT_ASSERT(!https);
#endif // ENABLE_SSL
CPPUNIT_ASSERT(!strSupportedFeature(MAX_FEATURE));
auto sftp = strSupportedFeature(FEATURE_SFTP);
#ifdef HAVE_LIBSSH2
CPPUNIT_ASSERT(sftp);
#else // !HAVE_LIBSSH2
CPPUNIT_ASSERT(!sftp);
#endif // !HAVE_LIBSSH2
}
void FeatureConfigTest::testFeatureSummary()
{
const std::string features[] = {
#ifdef ENABLE_ASYNC_DNS
"Async DNS",
#endif // ENABLE_ASYNC_DNS
#ifdef ENABLE_BITTORRENT
"BitTorrent",
#endif // ENABLE_BITTORRENT
#ifdef HAVE_SQLITE3
"Firefox3 Cookie",
#endif // HAVE_SQLITE3
#ifdef HAVE_ZLIB
"GZip",
#endif // HAVE_ZLIB
#ifdef ENABLE_SSL
"HTTPS",
#endif // ENABLE_SSL
"Message Digest",
#ifdef ENABLE_METALINK
"Metalink",
#endif // ENABLE_METALINK
#ifdef ENABLE_XML_RPC
"XML-RPC",
#endif // ENABLE_XML_RPC
#ifdef HAVE_LIBSSH2
"SFTP",
#endif // HAVE_LIBSSH2
};
std::string featuresString =
strjoin(std::begin(features), std::end(features), ", ");
CPPUNIT_ASSERT_EQUAL(featuresString, featureSummary());
}
} // namespace aria2