Add a first test for BDateTime.
* We need to write more of those.
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
@@ -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_
|
||||||
@@ -29,6 +29,9 @@ UnitTestLib libsupporttest.so
|
|||||||
AutolockLockerTest.cpp
|
AutolockLockerTest.cpp
|
||||||
AutolockLooperTest.cpp
|
AutolockLooperTest.cpp
|
||||||
|
|
||||||
|
# BDateTime
|
||||||
|
DateTimeTest.cpp
|
||||||
|
|
||||||
# BLocker (all in ./blocker)
|
# BLocker (all in ./blocker)
|
||||||
LockerTest.cpp
|
LockerTest.cpp
|
||||||
BenaphoreLockCountTest1.cpp
|
BenaphoreLockCountTest1.cpp
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "bstring/StringTest.h"
|
#include "bstring/StringTest.h"
|
||||||
#include "bblockcache/BlockCacheTest.h"
|
#include "bblockcache/BlockCacheTest.h"
|
||||||
#include "ByteOrderTest.h"
|
#include "ByteOrderTest.h"
|
||||||
|
#include "DateTimeTest.h"
|
||||||
|
|
||||||
|
|
||||||
BTestSuite *
|
BTestSuite *
|
||||||
@@ -20,6 +21,7 @@ getTestSuite()
|
|||||||
// ##### Add test suites here #####
|
// ##### Add test suites here #####
|
||||||
suite->addTest("BArchivable", ArchivableTestSuite());
|
suite->addTest("BArchivable", ArchivableTestSuite());
|
||||||
suite->addTest("BAutolock", AutolockTestSuite());
|
suite->addTest("BAutolock", AutolockTestSuite());
|
||||||
|
suite->addTest("BDateTime", DateTimeTestSuite());
|
||||||
suite->addTest("BLocker", LockerTestSuite());
|
suite->addTest("BLocker", LockerTestSuite());
|
||||||
suite->addTest("BMemoryIO", MemoryIOTestSuite());
|
suite->addTest("BMemoryIO", MemoryIOTestSuite());
|
||||||
suite->addTest("BMallocIO", MallocIOTestSuite());
|
suite->addTest("BMallocIO", MallocIOTestSuite());
|
||||||
|
|||||||
Reference in New Issue
Block a user