mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 13:37:40 +03:00
2009-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --save-cookies option. * src/Cookie.cc * src/Cookie.h * src/CookieStorage.cc * src/CookieStorage.h * src/MultiUrlRequestInfo.cc * src/OptionHandlerFactory.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/CookieStorageTest.cc * test/CookieTest.cc
This commit is contained in:
parent
5bad3a1c91
commit
383b12d7f1
12 changed files with 142 additions and 2 deletions
|
@ -22,6 +22,8 @@ class CookieStorageTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testLoad);
|
||||
CPPUNIT_TEST(testLoad_sqlite3);
|
||||
CPPUNIT_TEST(testLoad_fileNotfound);
|
||||
CPPUNIT_TEST(testSaveNsFormat);
|
||||
CPPUNIT_TEST(testSaveNsFormat_fail);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
public:
|
||||
void setUp() {}
|
||||
|
@ -34,6 +36,8 @@ public:
|
|||
void testLoad();
|
||||
void testLoad_sqlite3();
|
||||
void testLoad_fileNotfound();
|
||||
void testSaveNsFormat();
|
||||
void testSaveNsFormat_fail();
|
||||
};
|
||||
|
||||
|
||||
|
@ -261,4 +265,37 @@ void CookieStorageTest::testLoad_fileNotfound()
|
|||
}
|
||||
}
|
||||
|
||||
void CookieStorageTest::testSaveNsFormat()
|
||||
{
|
||||
std::string filename = "/tmp/aria2_CookieStorageTest_testSaveNsFormat";
|
||||
File(filename).remove();
|
||||
CookieStorage st;
|
||||
st.store(Cookie("uid","tujikawa","/",".domain.org",true));
|
||||
st.store(Cookie("favorite","classic","/config",".domain.org",false));
|
||||
st.saveNsFormat(filename);
|
||||
CookieStorage loadst;
|
||||
loadst.load(filename);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, loadst.size());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("uid"), (*loadst.begin()).getName());
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)0, (*loadst.begin()).getExpiry());
|
||||
CPPUNIT_ASSERT((*loadst.begin()).isSessionCookie());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("favorite"), (*(loadst.begin()+1)).getName());
|
||||
}
|
||||
|
||||
void CookieStorageTest::testSaveNsFormat_fail()
|
||||
{
|
||||
std::string filename = "/tmp/aria2_CookieStorageTest_testSaveNsFormat_fail";
|
||||
File f(filename);
|
||||
if(!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
CookieStorage st;
|
||||
try {
|
||||
st.saveNsFormat(filename);
|
||||
CPPUNIT_FAIL("exception should be thrown.");
|
||||
} catch(RecoverableException& e) {
|
||||
// OK
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue