Add tests for BDateTimeFormat with custom formats.

This commit is contained in:
Adrien Destugues
2014-10-07 13:07:06 +02:00
parent 4a3a474224
commit b16923f79f
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -25,6 +25,21 @@ DateFormatTest::~DateFormatTest()
}
void
DateFormatTest::TestCustomFormat()
{
int32 fields = B_DATE_ELEMENT_HOUR | B_DATE_ELEMENT_MINUTE;
BDateTimeFormat format;
BString buffer;
format.SetDateTimeFormat(B_SHORT_DATE_FORMAT, B_SHORT_TIME_FORMAT, fields);
status_t result = format.Format(buffer, 12345, B_SHORT_DATE_FORMAT,
B_SHORT_TIME_FORMAT);
CPPUNIT_ASSERT_EQUAL(B_OK, result);
CPPUNIT_ASSERT_EQUAL(BString("04:25"), buffer);
}
void
DateFormatTest::TestFormat()
{
@@ -113,6 +128,8 @@ DateFormatTest::AddTests(BTestSuite& parent)
{
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("DateFormatTest");
suite.addTest(new CppUnit::TestCaller<DateFormatTest>(
"DateFormatTest::TestCustomFormat", &DateFormatTest::TestCustomFormat));
suite.addTest(new CppUnit::TestCaller<DateFormatTest>(
"DateFormatTest::TestFormat", &DateFormatTest::TestFormat));
suite.addTest(new CppUnit::TestCaller<DateFormatTest>(
+1
View File
@@ -15,6 +15,7 @@ public:
DateFormatTest();
virtual ~DateFormatTest();
void TestCustomFormat();
void TestFormat();
void TestFormatDate();