mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 05:27:38 +03:00
2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: prefix to c++ standard classes. Included string.h where mem* function are used.
This commit is contained in:
parent
d82e183d34
commit
1b7c198289
801 changed files with 12024 additions and 8627 deletions
|
@ -1,8 +1,11 @@
|
|||
#include "HttpHeaderProcessor.h"
|
||||
#include "HttpHeader.h"
|
||||
#include "DlRetryEx.h"
|
||||
#include "DlAbortEx.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class HttpHeaderProcessorTest:public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(HttpHeaderProcessorTest);
|
||||
|
@ -37,7 +40,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( HttpHeaderProcessorTest );
|
|||
void HttpHeaderProcessorTest::testUpdate1()
|
||||
{
|
||||
HttpHeaderProcessor proc;
|
||||
string hd1 = "HTTP/1.1 200 OK\r\n";
|
||||
std::string hd1 = "HTTP/1.1 200 OK\r\n";
|
||||
proc.update(hd1);
|
||||
CPPUNIT_ASSERT(!proc.eoh());
|
||||
proc.update("\r\n");
|
||||
|
@ -47,7 +50,7 @@ void HttpHeaderProcessorTest::testUpdate1()
|
|||
void HttpHeaderProcessorTest::testUpdate2()
|
||||
{
|
||||
HttpHeaderProcessor proc;
|
||||
string hd1 = "HTTP/1.1 200 OK\n";
|
||||
std::string hd1 = "HTTP/1.1 200 OK\n";
|
||||
proc.update(hd1);
|
||||
CPPUNIT_ASSERT(!proc.eoh());
|
||||
proc.update("\n");
|
||||
|
@ -57,7 +60,7 @@ void HttpHeaderProcessorTest::testUpdate2()
|
|||
void HttpHeaderProcessorTest::testGetPutBackDataLength()
|
||||
{
|
||||
HttpHeaderProcessor proc;
|
||||
string hd1 = "HTTP/1.1 200 OK\r\n"
|
||||
std::string hd1 = "HTTP/1.1 200 OK\r\n"
|
||||
"\r\nputbackme";
|
||||
proc.update(hd1);
|
||||
CPPUNIT_ASSERT(proc.eoh());
|
||||
|
@ -65,7 +68,7 @@ void HttpHeaderProcessorTest::testGetPutBackDataLength()
|
|||
|
||||
proc.clear();
|
||||
|
||||
string hd2 = "HTTP/1.1 200 OK\n"
|
||||
std::string hd2 = "HTTP/1.1 200 OK\n"
|
||||
"\nputbackme";
|
||||
proc.update(hd2);
|
||||
CPPUNIT_ASSERT(proc.eoh());
|
||||
|
@ -86,7 +89,7 @@ void HttpHeaderProcessorTest::testGetPutBackDataLength_nullChar()
|
|||
void HttpHeaderProcessorTest::testGetHttpStatusHeader()
|
||||
{
|
||||
HttpHeaderProcessor proc;
|
||||
string hd = "HTTP/1.1 200 OK\r\n"
|
||||
std::string hd = "HTTP/1.1 200 OK\r\n"
|
||||
"Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n"
|
||||
"Server: Apache/2.2.3 (Debian)\r\n"
|
||||
"Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT\r\n"
|
||||
|
@ -99,14 +102,14 @@ void HttpHeaderProcessorTest::testGetHttpStatusHeader()
|
|||
|
||||
proc.update(hd);
|
||||
|
||||
pair<string, HttpHeaderHandle> statusHeader = proc.getHttpStatusHeader();
|
||||
string status = statusHeader.first;
|
||||
HttpHeaderHandle header = statusHeader.second;
|
||||
CPPUNIT_ASSERT_EQUAL(string("200"), status);
|
||||
CPPUNIT_ASSERT_EQUAL(string("Mon, 25 Jun 2007 16:04:59 GMT"), header->getFirst("Date"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("Apache/2.2.3 (Debian)"), header->getFirst("Server"));
|
||||
std::pair<std::string, SharedHandle<HttpHeader> > statusHeader = proc.getHttpStatusHeader();
|
||||
std::string status = statusHeader.first;
|
||||
SharedHandle<HttpHeader> header = statusHeader.second;
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("200"), status);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Mon, 25 Jun 2007 16:04:59 GMT"), header->getFirst("Date"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Apache/2.2.3 (Debian)"), header->getFirst("Server"));
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)9187LL, header->getFirstAsLLInt("Content-Length"));
|
||||
CPPUNIT_ASSERT_EQUAL(string("text/html; charset=UTF-8"), header->getFirst("Content-Type"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("text/html; charset=UTF-8"), header->getFirst("Content-Type"));
|
||||
}
|
||||
|
||||
void HttpHeaderProcessorTest::testGetHttpStatusHeader_empty()
|
||||
|
@ -114,10 +117,10 @@ void HttpHeaderProcessorTest::testGetHttpStatusHeader_empty()
|
|||
HttpHeaderProcessor proc;
|
||||
|
||||
try {
|
||||
pair<string, HttpHeaderHandle> statusHeader = proc.getHttpStatusHeader();
|
||||
std::pair<std::string, SharedHandle<HttpHeader> > statusHeader = proc.getHttpStatusHeader();
|
||||
CPPUNIT_FAIL("Exception must be thrown.");
|
||||
} catch(DlRetryEx* ex) {
|
||||
cout << ex->getMsg() << endl;
|
||||
std::cout << ex->getMsg() << std::endl;
|
||||
delete ex;
|
||||
}
|
||||
|
||||
|
@ -127,10 +130,10 @@ void HttpHeaderProcessorTest::testGetHttpStatusHeader_statusOnly()
|
|||
{
|
||||
HttpHeaderProcessor proc;
|
||||
|
||||
string hd = "HTTP/1.1 200\r\n\r\n";
|
||||
std::string hd = "HTTP/1.1 200\r\n\r\n";
|
||||
proc.update(hd);
|
||||
pair<string, HttpHeaderHandle> statusHeader = proc.getHttpStatusHeader();
|
||||
CPPUNIT_ASSERT_EQUAL(string("200"), statusHeader.first);
|
||||
std::pair<std::string, SharedHandle<HttpHeader> > statusHeader = proc.getHttpStatusHeader();
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("200"), statusHeader.first);
|
||||
CPPUNIT_ASSERT(!statusHeader.second.isNull());
|
||||
}
|
||||
|
||||
|
@ -138,13 +141,13 @@ void HttpHeaderProcessorTest::testGetHttpStatusHeader_insufficientStatusLength()
|
|||
{
|
||||
HttpHeaderProcessor proc;
|
||||
|
||||
string hd = "HTTP/1.1 20\r\n\r\n";
|
||||
std::string hd = "HTTP/1.1 20\r\n\r\n";
|
||||
proc.update(hd);
|
||||
try {
|
||||
pair<string, HttpHeaderHandle> statusHeader = proc.getHttpStatusHeader();
|
||||
std::pair<std::string, SharedHandle<HttpHeader> > statusHeader = proc.getHttpStatusHeader();
|
||||
CPPUNIT_FAIL("Exception must be thrown.");
|
||||
} catch(DlRetryEx* ex) {
|
||||
cout << ex->getMsg() << endl;
|
||||
std::cout << ex->getMsg() << std::endl;
|
||||
delete ex;
|
||||
}
|
||||
|
||||
|
@ -155,8 +158,8 @@ void HttpHeaderProcessorTest::testBeyondLimit()
|
|||
HttpHeaderProcessor proc;
|
||||
proc.setHeaderLimit(20);
|
||||
|
||||
string hd1 = "HTTP/1.1 200 OK\r\n";
|
||||
string hd2 = "Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n";
|
||||
std::string hd1 = "HTTP/1.1 200 OK\r\n";
|
||||
std::string hd2 = "Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n";
|
||||
|
||||
proc.update(hd1);
|
||||
|
||||
|
@ -164,7 +167,7 @@ void HttpHeaderProcessorTest::testBeyondLimit()
|
|||
proc.update(hd2);
|
||||
CPPUNIT_FAIL("Exception must be thrown.");
|
||||
} catch(DlAbortEx* ex) {
|
||||
cout << ex->getMsg() << endl;
|
||||
std::cout << ex->getMsg() << std::endl;
|
||||
delete ex;
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +175,7 @@ void HttpHeaderProcessorTest::testBeyondLimit()
|
|||
void HttpHeaderProcessorTest::testGetHeaderString()
|
||||
{
|
||||
HttpHeaderProcessor proc;
|
||||
string hd = "HTTP/1.1 200 OK\r\n"
|
||||
std::string hd = "HTTP/1.1 200 OK\r\n"
|
||||
"Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n"
|
||||
"Server: Apache/2.2.3 (Debian)\r\n"
|
||||
"Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT\r\n"
|
||||
|
@ -185,7 +188,7 @@ void HttpHeaderProcessorTest::testGetHeaderString()
|
|||
|
||||
proc.update(hd);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(string("HTTP/1.1 200 OK\r\n"
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1 200 OK\r\n"
|
||||
"Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n"
|
||||
"Server: Apache/2.2.3 (Debian)\r\n"
|
||||
"Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT\r\n"
|
||||
|
@ -196,3 +199,5 @@ void HttpHeaderProcessorTest::testGetHeaderString()
|
|||
"Content-Type: text/html; charset=UTF-8"),
|
||||
proc.getHeaderString());
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue