Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2014, Haiku, Inc. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
|
||
|
||
#include "DateTimeTest.h" | ||
|
||
#include <DateTime.h> | ||
|
||
#include <cppunit/TestSuite.h> | ||
|
||
|
||
class DateTimeTest : public BTestCase { | ||
public: | ||
DateTimeTest(std::string name = ""); | ||
|
||
void test(void); | ||
}; | ||
|
||
|
||
DateTimeTest::DateTimeTest(std::string name) | ||
: | ||
BTestCase(name) | ||
{ | ||
} | ||
|
||
|
||
void | ||
DateTimeTest::test() | ||
{ | ||
BDateTime dateTime; | ||
|
||
// Should be just one second before epoch | ||
dateTime.SetTime_t(-1); | ||
|
||
CPPUNIT_ASSERT(dateTime.IsValid()); | ||
CPPUNIT_ASSERT_EQUAL(59, dateTime.Time().Second()); | ||
CPPUNIT_ASSERT_EQUAL(59, dateTime.Time().Minute()); | ||
CPPUNIT_ASSERT_EQUAL(23, dateTime.Time().Hour()); | ||
CPPUNIT_ASSERT_EQUAL(31, dateTime.Date().Day()); | ||
CPPUNIT_ASSERT_EQUAL(12, dateTime.Date().Month()); | ||
CPPUNIT_ASSERT_EQUAL(1969, dateTime.Date().Year()); | ||
} | ||
|
||
|
||
CppUnit::Test* | ||
DateTimeTestSuite() | ||
{ | ||
CppUnit::TestSuite* testSuite = new CppUnit::TestSuite(); | ||
|
||
testSuite->addTest(new DateTimeTest("BDateTime")); | ||
|
||
return testSuite; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2014, Haiku, Inc. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#ifndef _DATE_TIME_TEST_H_ | ||
#define _DATE_TIME_TEST_H_ | ||
|
||
|
||
#include "TestCase.h" | ||
|
||
|
||
CppUnit::Test *DateTimeTestSuite(); | ||
|
||
|
||
#endif // _DATE_TIME_TEST_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters