Skip to content

Commit

Permalink
Add a first test for BDateTime.
Browse files Browse the repository at this point in the history
* We need to write more of those.
  • Loading branch information
pulkomandy committed Jun 16, 2014
1 parent dbd4f8c commit 4f88977
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/tests/kits/support/DateTimeTest.cpp
@@ -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;
}
15 changes: 15 additions & 0 deletions src/tests/kits/support/DateTimeTest.h
@@ -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_
3 changes: 3 additions & 0 deletions src/tests/kits/support/Jamfile
Expand Up @@ -29,6 +29,9 @@ UnitTestLib libsupporttest.so
AutolockLockerTest.cpp
AutolockLooperTest.cpp

# BDateTime
DateTimeTest.cpp

# BLocker (all in ./blocker)
LockerTest.cpp
BenaphoreLockCountTest1.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/tests/kits/support/SupportKitTestAddon.cpp
Expand Up @@ -10,6 +10,7 @@
#include "bstring/StringTest.h"
#include "bblockcache/BlockCacheTest.h"
#include "ByteOrderTest.h"
#include "DateTimeTest.h"


BTestSuite *
Expand All @@ -20,6 +21,7 @@ getTestSuite()
// ##### Add test suites here #####
suite->addTest("BArchivable", ArchivableTestSuite());
suite->addTest("BAutolock", AutolockTestSuite());
suite->addTest("BDateTime", DateTimeTestSuite());
suite->addTest("BLocker", LockerTestSuite());
suite->addTest("BMemoryIO", MemoryIOTestSuite());
suite->addTest("BMallocIO", MallocIOTestSuite());
Expand Down

0 comments on commit 4f88977

Please sign in to comment.