| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 | 
							- #include "NsCookieParser.h"
 
- #include "RecoverableException.h"
 
- #include "Util.h"
 
- #include <iostream>
 
- #include <cppunit/extensions/HelperMacros.h>
 
- namespace aria2 {
 
- class NsCookieParserTest:public CppUnit::TestFixture {
 
-   CPPUNIT_TEST_SUITE(NsCookieParserTest);
 
-   CPPUNIT_TEST(testParse);
 
-   CPPUNIT_TEST(testParse_fileNotFound);
 
-   CPPUNIT_TEST_SUITE_END();
 
- public:
 
-   void setUp() {}
 
-   void tearDown() {}
 
-   void testParse();
 
-   void testParse_fileNotFound();
 
- };
 
- CPPUNIT_TEST_SUITE_REGISTRATION(NsCookieParserTest);
 
- void NsCookieParserTest::testParse()
 
- {
 
-   NsCookieParser parser;
 
-   std::deque<Cookie> cookies = parser.parse("nscookietest.txt");
 
-   CPPUNIT_ASSERT_EQUAL((size_t)5, cookies.size());
 
-   Cookie c = cookies[0];
 
-   CPPUNIT_ASSERT_EQUAL(std::string("JSESSIONID"), c.getName());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("123456789"), c.getValue());
 
-   CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c.getExpiry());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("/"), c.getPath());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("localhost"), c.getDomain());
 
-   c = cookies[1];
 
-   CPPUNIT_ASSERT_EQUAL(std::string("user"), c.getName());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("me"), c.getValue());
 
-   CPPUNIT_ASSERT_EQUAL((time_t)1181473200, c.getExpiry());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("/"), c.getPath());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("expired"), c.getDomain());
 
-   c = cookies[2];
 
-   CPPUNIT_ASSERT_EQUAL(std::string("passwd"), c.getName());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("secret"), c.getValue());
 
-   CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c.getExpiry());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("/cgi-bin"), c.getPath());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("localhost"), c.getDomain());
 
-   c = cookies[3];
 
-   CPPUNIT_ASSERT_EQUAL(std::string("TAX"), c.getName());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("1000"), c.getValue());
 
-   CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c.getExpiry());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("/"), c.getPath());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("overflow"), c.getDomain());
 
-   c = cookies[4];
 
-   CPPUNIT_ASSERT_EQUAL(std::string("novalue"), c.getName());
 
-   CPPUNIT_ASSERT_EQUAL(std::string(""), c.getValue());
 
-   CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c.getExpiry());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("/"), c.getPath());
 
-   CPPUNIT_ASSERT_EQUAL(std::string("localhost"), c.getDomain());
 
- }
 
- void NsCookieParserTest::testParse_fileNotFound()
 
- {
 
-   NsCookieParser parser;
 
-   try {
 
-     parser.parse("fileNotFound");
 
-     CPPUNIT_FAIL("exception must be thrown.");
 
-   } catch(RecoverableException& e) {
 
-     // SUCCESS
 
-   }
 
- }
 
- } // namespace aria2
 
 
  |