diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-02-08 15:53:45 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-02-08 15:53:45 +0000 |
| commit | 1b7c1982896dba1d38e1fe84ba9660996607f5f9 (patch) | |
| tree | d12047cb37ded1e18d4d5b97844412538beb19ff /test/HttpHeaderProcessorTest.cc | |
| parent | d82e183d346375ac8a58a298a58728be615f947e (diff) | |
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.
Diffstat (limited to 'test/HttpHeaderProcessorTest.cc')
| -rw-r--r-- | test/HttpHeaderProcessorTest.cc | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/test/HttpHeaderProcessorTest.cc b/test/HttpHeaderProcessorTest.cc index 16f7b4b0..dd1af1a2 100644 --- a/test/HttpHeaderProcessorTest.cc +++ b/test/HttpHeaderProcessorTest.cc @@ -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 |
