clang-format-5.0

pull/1079/head
Tatsuhiro Tsujikawa 2017-11-23 14:11:43 +09:00
parent 20a7c43f2d
commit 795a0474df
48 changed files with 595 additions and 284 deletions

View File

@ -128,7 +128,8 @@ int main(int argc, char** argv)
if (dh) {
std::cerr << " [" << aria2::gidToHex(gid) << "] "
<< dh->getCompletedLength() << "/" << dh->getTotalLength()
<< "(" << (dh->getTotalLength() > 0
<< "("
<< (dh->getTotalLength() > 0
? (100 * dh->getCompletedLength() /
dh->getTotalLength())
: 0)

View File

@ -201,8 +201,9 @@ HANDLE openFileWithFlags(const std::string& filename, int flags,
FILE_ATTRIBUTE_NORMAL, /* hTemplateFile */ 0);
if (hn == INVALID_HANDLE_VALUE) {
int errNum = GetLastError();
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_OPEN, filename.c_str(),
fileStrerror(errNum).c_str()),
throw DL_ABORT_EX3(
errNum,
fmt(EX_FILE_OPEN, filename.c_str(), fileStrerror(errNum).c_str()),
errCode);
}
return hn;
@ -217,8 +218,9 @@ int openFileWithFlags(const std::string& filename, int flags,
;
if (fd < 0) {
int errNum = errno;
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_OPEN, filename.c_str(),
util::safeStrerror(errNum).c_str()),
throw DL_ABORT_EX3(
errNum,
fmt(EX_FILE_OPEN, filename.c_str(), util::safeStrerror(errNum).c_str()),
errCode);
}
util::make_fd_cloexec(fd);
@ -454,8 +456,9 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len,
error_code::NOT_ENOUGH_DISK_SPACE);
}
else {
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_WRITE, filename_.c_str(),
fileStrerror(errNum).c_str()),
throw DL_ABORT_EX3(
errNum,
fmt(EX_FILE_WRITE, filename_.c_str(), fileStrerror(errNum).c_str()),
error_code::FILE_IO_ERROR);
}
}
@ -467,8 +470,9 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len,
ssize_t ret;
if ((ret = readDataInternal(data, len, offset)) < 0) {
int errNum = fileError();
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_READ, filename_.c_str(),
fileStrerror(errNum).c_str()),
throw DL_ABORT_EX3(
errNum,
fmt(EX_FILE_READ, filename_.c_str(), fileStrerror(errNum).c_str()),
error_code::FILE_IO_ERROR);
}
return ret;
@ -526,16 +530,16 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
}
#elif defined(__APPLE__) && defined(__MACH__)
const auto toalloc = offset + length - size();
fstore_t fstore = {
F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE,
0, toalloc, 0};
fstore_t fstore = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0,
toalloc, 0};
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
// Retry non-contig.
fstore.fst_flags = F_ALLOCATEALL;
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
int err = errno;
throw DL_ABORT_EX3(
err, fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s",
err,
fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s",
fstore.fst_length, util::safeStrerror(err).c_str()),
error_code::FILE_IO_ERROR);
}
@ -559,8 +563,9 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
#elif HAVE_POSIX_FALLOCATE
int r = posix_fallocate(fd_, offset, length);
if (r != 0) {
throw DL_ABORT_EX3(r, fmt("posix_fallocate failed. cause: %s",
util::safeStrerror(r).c_str()),
throw DL_ABORT_EX3(
r,
fmt("posix_fallocate failed. cause: %s", util::safeStrerror(r).c_str()),
isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE
: error_code::FILE_IO_ERROR);
}

View File

@ -107,8 +107,8 @@ bool ActivePeerConnectionCommand::execute()
int numConnection = 0;
if (pieceStorage_->downloadFinished()) {
if (btRuntime_->getMaxPeers() > btRuntime_->getConnections()) {
numConnection = std::min(numNewConnection_,
btRuntime_->getMaxPeers() -
numConnection =
std::min(numNewConnection_, btRuntime_->getMaxPeers() -
btRuntime_->getConnections());
}
}

View File

@ -128,6 +128,6 @@ private:
OSStatus sockWrite(const void* data, size_t* len);
OSStatus sockRead(void* data, size_t* len);
};
}
} // namespace aria2
#endif // TLS_SESSION_H

View File

@ -78,7 +78,8 @@ void ChecksumCheckIntegrityEntry::onDownloadIncomplete(
std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
{
if (redownload_) {
proceedFileAllocation(commands, make_unique<StreamFileAllocationEntry>(
proceedFileAllocation(commands,
make_unique<StreamFileAllocationEntry>(
getRequestGroup(), popNextCommand()),
e);
return;

View File

@ -245,8 +245,7 @@ bool DHTBucket::operator==(const DHTBucket& bucket) const
bool DHTBucket::needsRefresh() const
{
return nodes_.size() < K ||
lastUpdated_.difference(global::wallclock()) >=
return nodes_.size() < K || lastUpdated_.difference(global::wallclock()) >=
DHT_BUCKET_REFRESH_INTERVAL;
}

View File

@ -87,8 +87,7 @@ bool DHTNode::isBad() const { return condition_ >= BAD_CONDITION; }
bool DHTNode::isQuestionable() const
{
return !isBad() &&
lastContact_.difference(global::wallclock()) >=
return !isBad() && lastContact_.difference(global::wallclock()) >=
DHT_NODE_CONTACT_INTERVAL;
}

View File

@ -55,6 +55,6 @@ struct DHTNodeLookupEntry {
bool operator==(const DHTNodeLookupEntry& entry) const;
};
} // namespace aria2;
} // namespace aria2
#endif // D_DHT_NODE_LOOKUP_ENTRY_H

View File

@ -235,8 +235,8 @@ bool FtpConnection::sendPort(const std::shared_ptr<SocketCore>& serverSocket)
bool FtpConnection::sendRest(const std::shared_ptr<Segment>& segment)
{
if (socketBuffer_.sendBufferIsEmpty()) {
std::string request = fmt("REST %" PRId64 "\r\n",
segment ? segment->getPositionToWrite()
std::string request =
fmt("REST %" PRId64 "\r\n", segment ? segment->getPositionToWrite()
: static_cast<int64_t>(0LL));
A2_LOG_INFO(fmt(MSG_SENDING_REQUEST, cuid_, request.c_str()));
socketBuffer_.pushStr(std::move(request));

View File

@ -163,6 +163,6 @@ public:
int idInterestingHeader(const char* hdName);
} // namespace
} // namespace aria2
#endif // D_HTTP_HEADER_H

View File

@ -279,8 +279,7 @@ bool HttpResponseCommand::executeInternal()
// we ignore content-length when inflate is required
fe->setLength(0);
if (req->getMethod() == Request::METHOD_GET &&
(totalLength != 0 ||
!httpResponse->getHttpHeader()->defined(
(totalLength != 0 || !httpResponse->getHttpHeader()->defined(
HttpHeader::CONTENT_LENGTH))) {
// DownloadContext::knowsTotalLength() == true only when
// server says the size of file is 0 explicitly.
@ -422,9 +421,8 @@ bool HttpResponseCommand::handleOtherEncoding(
httpResponse.get(), getContentEncodingStreamFilter(httpResponse.get()));
// If chunked transfer-encoding is specified, we have to read end of
// chunk markers(0\r\n\r\n, for example).
bool chunkedUsed =
streamFilter &&
streamFilter->getName() == ChunkedDecodingStreamFilter::NAME;
bool chunkedUsed = streamFilter && streamFilter->getName() ==
ChunkedDecodingStreamFilter::NAME;
// For zero-length file, check existing file comparing its size
if (!chunkedUsed && getDownloadContext()->knowsTotalLength() &&

View File

@ -57,8 +57,8 @@ namespace util {
namespace security {
class HMAC;
class HMACResult;
}
}
} // namespace security
} // namespace util
enum RequestType { RPC_TYPE_NONE, RPC_TYPE_XML, RPC_TYPE_JSON, RPC_TYPE_JSONP };

View File

@ -107,8 +107,8 @@ int GnuTLSSession::init(sock_t sockfd)
rv_ = gnutls_init(&sslSession_, flags);
#else // GNUTLS_VERSION_NUMBER >= 0x030000
rv_ = gnutls_init(&sslSession_,
tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT
rv_ = gnutls_init(&sslSession_, tlsContext_->getSide() == TLS_CLIENT
? GNUTLS_CLIENT
: GNUTLS_SERVER);
#endif // GNUTLS_VERSION_NUMBER >= 0x030000
if (rv_ != GNUTLS_E_SUCCESS) {

View File

@ -125,8 +125,7 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer)
};
// Disable SSLv2 and enable all workarounds for buggy servers
SSL_CTX_set_options(sslCtx_,
SSL_OP_ALL | SSL_OP_NO_SSLv2 | ver_opts
SSL_CTX_set_options(sslCtx_, SSL_OP_ALL | SSL_OP_NO_SSLv2 | ver_opts
#ifdef SSL_OP_SINGLE_ECDH_USE
| SSL_OP_SINGLE_ECDH_USE
#endif // SSL_OP_SINGLE_ECDH_USE

View File

@ -66,7 +66,7 @@ template <typename T> static void close_callback(uv_handle_t* handle)
}
static void timer_callback(uv_timer_t* handle) { uv_stop(handle->loop); }
}
} // namespace
namespace aria2 {

View File

@ -121,4 +121,4 @@ std::string createLpdRequest(const std::string& multicastAddress,
} // namespace bittorrent
} // namespac aria2
} // namespace aria2

View File

@ -61,7 +61,7 @@ HashTypeEntry hashTypes[] = {
HashTypeEntry("sha-512", 5), HashTypeEntry("md5", 0),
HashTypeEntry("adler32", 0),
};
} // namespace aria2
} // namespace
MessageDigest::MessageDigest(std::unique_ptr<MessageDigestImpl> impl)
: pImpl_{std::move(impl)}

View File

@ -139,8 +139,9 @@ void Metalink2RequestGroup::generate(
const std::shared_ptr<Option>& option, const std::string& baseUri)
{
std::vector<std::shared_ptr<RequestGroup>> tempgroups;
createRequestGroup(tempgroups, metalink::parseAndQuery(binaryStream.get(),
option.get(), baseUri),
createRequestGroup(
tempgroups,
metalink::parseAndQuery(binaryStream.get(), option.get(), baseUri),
option);
auto mi = std::make_shared<MetadataInfo>();
setMetadataInfo(std::begin(tempgroups), std::end(tempgroups), mi);

View File

@ -62,6 +62,6 @@ public:
} // namespace rpc
} // aria2
} // namespace aria2
#endif // D_NULL_WEB_SOCKET_SESSION_MAN_H

View File

@ -67,9 +67,8 @@ void OpenedFileCounter::ensureMaxOpenFileLimit(size_t numNewFiles)
auto& requestGroups = rgman_->getRequestGroups();
auto mark = std::begin(requestGroups);
std::advance(
mark,
SimpleRandomizer::getInstance()->getRandomNumber(requestGroups.size()));
std::advance(mark, SimpleRandomizer::getInstance()->getRandomNumber(
requestGroups.size()));
auto closeFun = [&left](const std::shared_ptr<RequestGroup>& group) {
auto& ps = group->getPieceStorage();

View File

@ -1480,9 +1480,9 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op);
}
{
OptionHandler* op(new DefaultOptionHandler(PREF_BT_EXCLUDE_TRACKER,
TEXT_BT_EXCLUDE_TRACKER,
NO_DESCRIPTION, "URI,... "
OptionHandler* op(new DefaultOptionHandler(
PREF_BT_EXCLUDE_TRACKER, TEXT_BT_EXCLUDE_TRACKER, NO_DESCRIPTION,
"URI,... "
"or *"));
op->addTag(TAG_BITTORRENT);
op->setInitialOption(true);

View File

@ -85,7 +85,7 @@ void gnutls_log_callback(int level, const char* str)
msg.resize(msg.size() - 1);
A2_LOG_DEBUG(fmt("GnuTLS: <%d> %s", level, msg.c_str()));
}
}
} // namespace
#endif // HAVE_LIBGNUTLS
bool Platform::initialized_ = false;

View File

@ -791,8 +791,9 @@ void gatherProgress(Dict* entryDict, const std::shared_ptr<RequestGroup>& group,
gatherProgressCommon(entryDict, group, keys);
#ifdef ENABLE_BITTORRENT
if (group->getDownloadContext()->hasAttribute(CTX_ATTR_BT)) {
gatherProgressBitTorrent(entryDict, group, bittorrent::getTorrentAttrs(
group->getDownloadContext()),
gatherProgressBitTorrent(
entryDict, group,
bittorrent::getTorrentAttrs(group->getDownloadContext()),
e->getBtRegistry()->get(group->getGID()), keys);
}
#endif // ENABLE_BITTORRENT

View File

@ -135,6 +135,6 @@ private:
LIBSSH2_SFTP_HANDLE* sftph_;
sock_t fd_;
};
}
} // namespace aria2
#endif // SSH_SESSION_H

View File

@ -223,13 +223,11 @@ bool writeDownloadResult(IOFile& fp, std::set<a2_gid_t>& metainfoCache,
// also exists in remaining URIs.
{
Unique<std::string> unique;
if (hasRemaining &&
!writeUri(fp, file->getRemainingUris().begin(),
if (hasRemaining && !writeUri(fp, file->getRemainingUris().begin(),
file->getRemainingUris().end(), unique)) {
return false;
}
if (hasSpent &&
!writeUri(fp, file->getSpentUris().begin(),
if (hasSpent && !writeUri(fp, file->getSpentUris().begin(),
file->getSpentUris().end(), unique)) {
return false;
}

View File

@ -58,7 +58,8 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete(
if (getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY)) {
return;
}
proceedFileAllocation(commands, make_unique<StreamFileAllocationEntry>(
proceedFileAllocation(commands,
make_unique<StreamFileAllocationEntry>(
getRequestGroup(), popNextCommand()),
e);
}

View File

@ -118,6 +118,6 @@ private:
TLSSession(const TLSSession&);
TLSSession& operator=(const TLSSession&);
};
}
} // namespace aria2
#endif // TLS_SESSION_H

View File

@ -47,7 +47,7 @@ class ValueBase;
namespace rpc {
class XmlRpcRequestParserController;
} // namespace rpc;
} // namespace rpc
class ValueBaseStructParserState;

View File

@ -55,8 +55,8 @@ WebSocketResponseCommand::~WebSocketResponseCommand() = default;
void WebSocketResponseCommand::afterSend(
const std::shared_ptr<HttpServer>& httpServer, DownloadEngine* e)
{
auto wsSession = std::make_shared<WebSocketSession>(
httpServer->getSocket(), getDownloadEngine());
auto wsSession = std::make_shared<WebSocketSession>(httpServer->getSocket(),
getDownloadEngine());
auto command = make_unique<WebSocketInteractionCommand>(
getCuid(), wsSession, e, wsSession->getSocket());
wsSession->setCommand(command.get());

View File

@ -69,6 +69,6 @@ private:
} // namespace rpc
} // aria2
} // namespace aria2
#endif // D_WEB_SOCKET_SESSION_MAN_H

View File

@ -48,7 +48,7 @@ namespace {
Console consoleCout;
Console consoleCerr;
Console consoleCoutBackup;
};
}; // namespace
void initConsole(bool suppress)
{

View File

@ -810,28 +810,375 @@ static const uint8_t utf8d[] = {
* The first part of the table maps bytes to character classes that
* to reduce the size of the transition table and create bitmasks.
*/
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
8,
8,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
10,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3,
4,
3,
3,
11,
6,
6,
6,
5,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
/*
* The second part is a transition table that maps a combination
* of a state of the automaton and a character class to a state.
*/
0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12,
12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12,
12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12,
12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12,
12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
0,
12,
24,
36,
60,
96,
84,
12,
12,
12,
48,
72,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
0,
12,
12,
12,
12,
12,
0,
12,
0,
12,
12,
12,
24,
12,
12,
12,
12,
12,
24,
12,
24,
12,
12,
12,
12,
12,
12,
12,
12,
12,
24,
12,
12,
12,
12,
12,
24,
12,
12,
12,
12,
12,
12,
12,
24,
12,
12,
12,
12,
12,
12,
12,
12,
12,
36,
12,
36,
12,
12,
12,
36,
12,
12,
12,
12,
12,
36,
12,
36,
12,
12,
12,
36,
12,
12,
12,
12,
12,
12,
12,
12,
12,
12,
};
static uint32_t utf8dfa(uint32_t* state, uint32_t* codep, uint32_t byte)
@ -1341,7 +1688,7 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
}
return FALSE;
}
}
} // namespace
#endif
void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
@ -1598,8 +1945,9 @@ void mkdirs(const std::string& dirpath)
if (!dir.mkdirs()) {
int errNum = errno;
if (!dir.isDir()) {
throw DL_ABORT_EX3(errNum, fmt(EX_MAKE_DIR, dir.getPath().c_str(),
safeStrerror(errNum).c_str()),
throw DL_ABORT_EX3(
errNum,
fmt(EX_MAKE_DIR, dir.getPath().c_str(), safeStrerror(errNum).c_str()),
error_code::DIR_CREATE_ERROR);
}
}
@ -1840,8 +2188,7 @@ std::string escapePath(const std::string& s)
unsigned char c = cc;
if (in(c, 0x00u, 0x1fu) || c == 0x7fu
#ifdef __MINGW32__
||
std::find(std::begin(WIN_INVALID_PATH_CHARS),
|| std::find(std::begin(WIN_INVALID_PATH_CHARS),
std::end(WIN_INVALID_PATH_CHARS),
c) != std::end(WIN_INVALID_PATH_CHARS)
#endif // __MINGW32__

View File

@ -209,10 +209,9 @@ void ChunkedDecodingStreamFilterTest::testTransform()
void ChunkedDecodingStreamFilterTest::testTransform_withoutTrailer()
{
CPPUNIT_ASSERT_EQUAL(
(ssize_t)0,
filter_->transform(writer_, segment_,
reinterpret_cast<const unsigned char*>("0\r\n\r\n"),
5));
(ssize_t)0, filter_->transform(
writer_, segment_,
reinterpret_cast<const unsigned char*>("0\r\n\r\n"), 5));
CPPUNIT_ASSERT(filter_->finished());
}

View File

@ -113,12 +113,10 @@ void HandshakeExtensionMessageTest::testDoReceivedAction()
msg.doReceivedAction();
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->getPort());
CPPUNIT_ASSERT_EQUAL(
(uint8_t)1,
peer->getExtensionMessageID(ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL(
(uint8_t)3,
peer->getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA));
CPPUNIT_ASSERT_EQUAL((uint8_t)1, peer->getExtensionMessageID(
ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL((uint8_t)3, peer->getExtensionMessageID(
ExtensionMessageRegistry::UT_METADATA));
CPPUNIT_ASSERT(peer->isSeeder());
auto attrs = bittorrent::getTorrentAttrs(dctx);
CPPUNIT_ASSERT_EQUAL((size_t)1_k, attrs->metadataSize);

View File

@ -625,7 +625,8 @@ void HttpRequestTest::testCreateRequest_wantDigest()
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
"Want-Digest: " +
wantDigest + "\r\n"
wantDigest +
"\r\n"
"\r\n";
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());

View File

@ -405,7 +405,7 @@ namespace {
struct RemoveOdd {
bool operator()(int* p) const { return *p % 2 == 1; }
};
}
} // namespace
void IndexedListTest::testRemoveIf()
{
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

View File

@ -140,9 +140,8 @@ void PeerSessionResourceTest::testGetExtensionMessageID()
res.addExtension(ExtensionMessageRegistry::UT_PEX, 9);
CPPUNIT_ASSERT_EQUAL(
(uint8_t)9, res.getExtensionMessageID(ExtensionMessageRegistry::UT_PEX));
CPPUNIT_ASSERT_EQUAL(
(uint8_t)0,
res.getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA));
CPPUNIT_ASSERT_EQUAL((uint8_t)0, res.getExtensionMessageID(
ExtensionMessageRegistry::UT_METADATA));
CPPUNIT_ASSERT_EQUAL(std::string("ut_pex"),
std::string(res.getExtensionName(9)));

View File

@ -149,53 +149,38 @@ void RequestGroupManTest::testChangeReservedGroupPosition()
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_))};
RequestGroupMan rm(gs, 0, option_.get());
CPPUNIT_ASSERT_EQUAL(
(size_t)0,
rm.changeReservedGroupPosition(gs[0]->getGID(), 0, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL(
(size_t)1,
rm.changeReservedGroupPosition(gs[0]->getGID(), 1, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL(
(size_t)3,
rm.changeReservedGroupPosition(gs[0]->getGID(), 10, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL(
(size_t)0,
rm.changeReservedGroupPosition(gs[0]->getGID(), -10, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
gs[0]->getGID(), 0, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
gs[0]->getGID(), 1, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
gs[0]->getGID(), 10, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
gs[0]->getGID(), -10, OFFSET_MODE_SET));
CPPUNIT_ASSERT_EQUAL(
(size_t)1,
rm.changeReservedGroupPosition(gs[1]->getGID(), 0, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)2,
rm.changeReservedGroupPosition(gs[1]->getGID(), 1, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)1,
rm.changeReservedGroupPosition(gs[1]->getGID(), -1, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)0,
rm.changeReservedGroupPosition(gs[1]->getGID(), -10, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)1,
rm.changeReservedGroupPosition(gs[1]->getGID(), 1, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)3,
rm.changeReservedGroupPosition(gs[1]->getGID(), 10, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)1,
rm.changeReservedGroupPosition(gs[1]->getGID(), -2, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
gs[1]->getGID(), 0, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)2, rm.changeReservedGroupPosition(
gs[1]->getGID(), 1, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
gs[1]->getGID(), -1, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
gs[1]->getGID(), -10, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
gs[1]->getGID(), 1, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
gs[1]->getGID(), 10, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
gs[1]->getGID(), -2, OFFSET_MODE_CUR));
CPPUNIT_ASSERT_EQUAL(
(size_t)3,
rm.changeReservedGroupPosition(gs[3]->getGID(), 0, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL(
(size_t)2,
rm.changeReservedGroupPosition(gs[3]->getGID(), -1, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL(
(size_t)0,
rm.changeReservedGroupPosition(gs[3]->getGID(), -10, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL(
(size_t)3,
rm.changeReservedGroupPosition(gs[3]->getGID(), 10, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
gs[3]->getGID(), 0, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL((size_t)2, rm.changeReservedGroupPosition(
gs[3]->getGID(), -1, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
gs[3]->getGID(), -10, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
gs[3]->getGID(), 10, OFFSET_MODE_END));
CPPUNIT_ASSERT_EQUAL((size_t)4, rm.getReservedGroups().size());

View File

@ -369,8 +369,7 @@ void RpcMethodTest::testAddTorrent()
CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR) +
"/aria2-0.8.2.tar.bz2",
group->getFirstFilePath());
CPPUNIT_ASSERT_EQUAL((size_t)1,
group->getDownloadContext()
CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()
->getFirstFileEntry()
->getRemainingUris()
.size());
@ -1288,7 +1287,9 @@ void RpcMethodTest::testGetSessionInfo()
void RpcMethodTest::testPause()
{
std::vector<std::string> uris{
"http://url1", "http://url2", "http://url3",
"http://url1",
"http://url2",
"http://url3",
};
option_->put(PREF_FORCE_SEQUENTIAL, A2_V_TRUE);
std::vector<std::shared_ptr<RequestGroup>> groups;

View File

@ -61,8 +61,7 @@ void UriSplitTest::testUriSplit()
uri = "http://user@aria2.sf.net/path/";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_USERINFO) | (1 << USR_USER));
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
@ -72,8 +71,7 @@ void UriSplitTest::testUriSplit()
uri = "http://user:pass@aria2.sf.net/path/";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
@ -89,8 +87,7 @@ void UriSplitTest::testUriSplit()
uri = "http://user@foo.com:pass@aria2.sf.net/path/";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
@ -104,8 +101,7 @@ void UriSplitTest::testUriSplit()
uri = "https://aria2.sf.net:443/path/";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_PATH));
CPPUNIT_ASSERT_EQUAL(std::string("https"), mkstr(res, USR_SCHEME, uri));
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
@ -116,10 +112,9 @@ void UriSplitTest::testUriSplit()
uri = "https://user:pass@aria2.sf.net:443/path/";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_PATH) | (1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_PATH) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
@ -131,9 +126,9 @@ void UriSplitTest::testUriSplit()
uri = "https://user@aria2.sf.net:443/path/";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_PATH) | (1 << USR_USERINFO) | (1 << USR_USER));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_PATH) | (1 << USR_USERINFO) |
(1 << USR_USER));
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
@ -157,9 +152,8 @@ void UriSplitTest::testUriSplit()
uri = "http://user@aria2";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
(1 << USR_USER));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
(1 << USR_USERINFO) | (1 << USR_USER));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
@ -167,9 +161,9 @@ void UriSplitTest::testUriSplit()
uri = "http://user:@aria2";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user:"), mkstr(res, USR_USERINFO, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
@ -178,8 +172,7 @@ void UriSplitTest::testUriSplit()
uri = "http://aria2/?foo#bar";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_QUERY) | (1 << USR_FRAGMENT));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
@ -207,8 +200,7 @@ void UriSplitTest::testUriSplit()
uri = "https://aria2:443?foo";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_QUERY));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("foo"), mkstr(res, USR_QUERY, uri));
@ -218,8 +210,7 @@ void UriSplitTest::testUriSplit()
uri = "https://aria2:443#bar";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_FRAGMENT));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("bar"), mkstr(res, USR_FRAGMENT, uri));
@ -229,10 +220,9 @@ void UriSplitTest::testUriSplit()
uri = "https://user:pass@aria2:443?foo";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_QUERY) | (1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_QUERY) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
CPPUNIT_ASSERT_EQUAL(std::string("pass"), mkstr(res, USR_PASSWD, uri));
@ -243,8 +233,7 @@ void UriSplitTest::testUriSplit()
uri = "https://user:pass@aria2:443#bar";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_FRAGMENT) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
@ -257,8 +246,7 @@ void UriSplitTest::testUriSplit()
uri = "http://user:pass@aria2?foo";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_QUERY) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_QUERY) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
@ -270,10 +258,9 @@ void UriSplitTest::testUriSplit()
uri = "http://user:pass@aria2#bar";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_FRAGMENT) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
(1 << USR_FRAGMENT) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
CPPUNIT_ASSERT_EQUAL(std::string("pass"), mkstr(res, USR_PASSWD, uri));
@ -283,8 +270,7 @@ void UriSplitTest::testUriSplit()
uri = "http://aria2/?";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_QUERY));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
@ -294,8 +280,7 @@ void UriSplitTest::testUriSplit()
uri = "http://aria2/#";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_FRAGMENT));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
@ -305,8 +290,7 @@ void UriSplitTest::testUriSplit()
uri = "http://aria2/?#";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_QUERY) | (1 << USR_FRAGMENT));
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
@ -333,9 +317,8 @@ void UriSplitTest::testUriSplit()
uri = "https://user@[::1]";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
(1 << USR_USER));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
(1 << USR_USERINFO) | (1 << USR_USER));
CPPUNIT_ASSERT_EQUAL(std::string("::1"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
@ -345,9 +328,9 @@ void UriSplitTest::testUriSplit()
uri = "https://user:pass@[::1]";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD));
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD));
CPPUNIT_ASSERT_EQUAL(std::string("::1"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
@ -357,8 +340,7 @@ void UriSplitTest::testUriSplit()
uri = "http://aria2/f";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_BASENAME));
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
CPPUNIT_ASSERT_EQUAL(std::string("f"), mkstr(res, USR_BASENAME, uri));
@ -366,8 +348,7 @@ void UriSplitTest::testUriSplit()
uri = "http://[::1]/f";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_BASENAME));
CPPUNIT_ASSERT_EQUAL(std::string("::1"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
@ -376,8 +357,7 @@ void UriSplitTest::testUriSplit()
uri = "http://[::1]:8080/f";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
(1 << USR_PATH) | (1 << USR_BASENAME));
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, res.port);
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
@ -386,9 +366,9 @@ void UriSplitTest::testUriSplit()
uri = "https://user:pass@host/f";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
(1 << USR_USER) | (1 << USR_PASSWD) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
(1 << USR_USERINFO) | (1 << USR_USER) |
(1 << USR_PASSWD) | (1 << USR_PATH) |
(1 << USR_BASENAME));
CPPUNIT_ASSERT_EQUAL(std::string("host"), mkstr(res, USR_HOST, uri));
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
@ -398,8 +378,7 @@ void UriSplitTest::testUriSplit()
uri = "http://aria2/index.html?foo";
memset(&res, 0, sizeof(res));
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
CHECK_FIELD_SET(res,
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
(1 << USR_QUERY) | (1 << USR_BASENAME));
CPPUNIT_ASSERT_EQUAL(std::string("/index.html"), mkstr(res, USR_PATH, uri));
CPPUNIT_ASSERT_EQUAL(std::string("index.html"),