From 9577c31bfe3c1543268e5be7bc9581d085d6a9ae Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 1 Oct 2014 18:23:54 +0200 Subject: [PATCH] Convert BTimeFormat tests to cppunit. --- src/tests/kits/locale/DateFormatTest.cpp | 27 ++++++++++++++++++------ src/tests/kits/locale/Jamfile | 1 - src/tests/kits/locale/formatTest.cpp | 21 ------------------ 3 files changed, 21 insertions(+), 28 deletions(-) delete mode 100644 src/tests/kits/locale/formatTest.cpp diff --git a/src/tests/kits/locale/DateFormatTest.cpp b/src/tests/kits/locale/DateFormatTest.cpp index 2cc1d4149f..201d2d11b3 100644 --- a/src/tests/kits/locale/DateFormatTest.cpp +++ b/src/tests/kits/locale/DateFormatTest.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -33,12 +34,17 @@ DateFormatTest::TestFormat() time_t time; char* shortDate; char* longDate; + char* shortTime; + char* longTime; }; static const Value values[] = { - {"en", "en_US", 12345, "1/1/70", "January 1, 1970"}, - {"fr", "fr_FR", 12345, "01/01/70", "1 janvier 1970"}, - {"fr", "fr_FR", 12345678, "23/05/70", "23 mai 1970"}, + {"en", "en_US", 12345, "1/1/70", "January 1, 1970", + "4:25 AM", "4:25:45 AM CET"}, + {"fr", "fr_FR", 12345, "01/01/70", "1 janvier 1970", + "04:25", "04:25:45 HNEC"}, + {"fr", "fr_FR", 12345678, "23/05/70", "23 mai 1970", + "22:21", "22:21:18 HNEC"}, {NULL} }; @@ -50,15 +56,24 @@ DateFormatTest::TestFormat() BLanguage language(values[i].language); BFormattingConventions formatting(values[i].convention); - BDateFormat format(&language, &formatting); + BDateFormat dateFormat(&language, &formatting); + BTimeFormat timeFormat(&language, &formatting); - result = format.Format(output, values[i].time, B_SHORT_DATE_FORMAT); + result = dateFormat.Format(output, values[i].time, B_SHORT_DATE_FORMAT); CPPUNIT_ASSERT_EQUAL(B_OK, result); CPPUNIT_ASSERT_EQUAL(BString(values[i].shortDate), output); - result = format.Format(output, values[i].time, B_LONG_DATE_FORMAT); + result = dateFormat.Format(output, values[i].time, B_LONG_DATE_FORMAT); CPPUNIT_ASSERT_EQUAL(B_OK, result); CPPUNIT_ASSERT_EQUAL(BString(values[i].longDate), output); + + result = timeFormat.Format(output, values[i].time, B_SHORT_TIME_FORMAT); + CPPUNIT_ASSERT_EQUAL(B_OK, result); + CPPUNIT_ASSERT_EQUAL(BString(values[i].shortTime), output); + + result = timeFormat.Format(output, values[i].time, B_LONG_TIME_FORMAT); + CPPUNIT_ASSERT_EQUAL(B_OK, result); + CPPUNIT_ASSERT_EQUAL(BString(values[i].longTime), output); } } diff --git a/src/tests/kits/locale/Jamfile b/src/tests/kits/locale/Jamfile index 0de09ffb58..af5166c2c1 100644 --- a/src/tests/kits/locale/Jamfile +++ b/src/tests/kits/locale/Jamfile @@ -31,7 +31,6 @@ LocaleTest catalogTest.cpp ; LocaleTest collatorSpeed.cpp ; LocaleTest collatorTest.cpp ; LocaleTest genericNumberFormatTest.cpp ; -LocaleTest formatTest.cpp ; Includes [ FGristFiles ICUTest.cpp ] : [ BuildFeatureAttribute icu : headers ] ; # Dependency needed to trigger downloading/unzipping the package before diff --git a/src/tests/kits/locale/formatTest.cpp b/src/tests/kits/locale/formatTest.cpp deleted file mode 100644 index 203429f58c..0000000000 --- a/src/tests/kits/locale/formatTest.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - -#include - -#include -#include - -int -main() -{ - BTimeFormat timeFormatter; - BString str; - - if (timeFormatter.Format(123456, &str) != B_OK) { - std::cout << "Conversion error\n"; - return -1; - } - - std::cout << str.String() << std::endl; - return 0; -}