mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 14:07:37 +03:00
2008-09-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implmented the functions to parse date. * src/TimeA2.cc * src/TimeA2.h * test/TimeTest.cc
This commit is contained in:
parent
9fc8b15736
commit
69b18308d9
6 changed files with 155 additions and 5 deletions
65
test/TimeTest.cc
Normal file
65
test/TimeTest.cc
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include "TimeA2.h"
|
||||
#include "Exception.h"
|
||||
#include "Util.h"
|
||||
#include <iostream>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class TimeTest:public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(TimeTest);
|
||||
CPPUNIT_TEST(testParseRFC1123);
|
||||
CPPUNIT_TEST(testParseRFC850);
|
||||
CPPUNIT_TEST(testParseRFC850Ext);
|
||||
CPPUNIT_TEST(testParseHTTPDate);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
public:
|
||||
void setUp() {}
|
||||
|
||||
void tearDown() {}
|
||||
|
||||
void testParseRFC1123();
|
||||
void testParseRFC850();
|
||||
void testParseRFC850Ext();
|
||||
void testParseHTTPDate();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TimeTest);
|
||||
|
||||
void TimeTest::testParseRFC1123()
|
||||
{
|
||||
Time t1 = Time::parseRFC1123("Sat, 06 Sep 2008 15:26:33 GMT");
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793, t1.getTime());
|
||||
}
|
||||
|
||||
void TimeTest::testParseRFC850()
|
||||
{
|
||||
Time t1 = Time::parseRFC850("Saturday, 06-Sep-08 15:26:33 GMT");
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793, t1.getTime());
|
||||
}
|
||||
|
||||
void TimeTest::testParseRFC850Ext()
|
||||
{
|
||||
Time t1 = Time::parseRFC850Ext("Saturday, 06-Sep-2008 15:26:33 GMT");
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793, t1.getTime());
|
||||
}
|
||||
|
||||
void TimeTest::testParseHTTPDate()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793,
|
||||
Time::parseHTTPDate
|
||||
("Sat, 06 Sep 2008 15:26:33 GMT").getTime());
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793,
|
||||
Time::parseHTTPDate
|
||||
("Sat, 06-Sep-2008 15:26:33 GMT").getTime());
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793,
|
||||
Time::parseHTTPDate
|
||||
("Sat, 06-Sep-08 15:26:33 GMT").getTime());
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)-1,
|
||||
Time::parseHTTPDate
|
||||
("Sat, 2008-09-06 15:26:33 GMT").getTime());
|
||||
}
|
||||
|
||||
} // namespace aria2
|
Loading…
Add table
Add a link
Reference in a new issue