2008-09-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Added a constuctor that receives struct timeval.
	Added operator<.
	* src/TimeA2.cc
	* src/TimeA2.h
	* test/TimeTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2008-09-07 04:57:31 +00:00
parent b624a12ed0
commit 5fb94a3af0
4 changed files with 42 additions and 2 deletions

View file

@ -13,6 +13,7 @@ class TimeTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testParseRFC850);
CPPUNIT_TEST(testParseRFC850Ext);
CPPUNIT_TEST(testParseHTTPDate);
CPPUNIT_TEST(testOperatorLess);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
@ -23,6 +24,7 @@ public:
void testParseRFC850();
void testParseRFC850Ext();
void testParseHTTPDate();
void testOperatorLess();
};
@ -62,4 +64,22 @@ void TimeTest::testParseHTTPDate()
("Sat, 2008-09-06 15:26:33 GMT").getTime());
}
void TimeTest::testOperatorLess()
{
CPPUNIT_ASSERT(Time(1) < Time(2));
CPPUNIT_ASSERT(!(Time(1) < Time(1)));
CPPUNIT_ASSERT(!(Time(2) < Time(1)));
struct timeval tv1;
tv1.tv_sec = 0;
tv1.tv_usec = 1;
struct timeval tv2;
tv2.tv_sec = 1;
tv2.tv_usec = 0;
CPPUNIT_ASSERT(Time(tv1) < Time(tv2));
tv2.tv_sec = 0;
CPPUNIT_ASSERT(Time(tv2) < Time(tv1));
}
} // namespace aria2