Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: source/test/intltest/tufmtts.cpp

Issue 1621943002: ICU 56 step 4: Apply post-56 fixes for measure/date format (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@56goog
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/test/intltest/tufmtts.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/test/intltest/tufmtts.cpp
diff --git a/source/test/intltest/tufmtts.cpp b/source/test/intltest/tufmtts.cpp
index 8ed9b9f7956a9f16c677bc46fe6bf54ef5a5e4ac..6b1ed5a0080f2878a43725ae3a12f3d3992164cf 100644
--- a/source/test/intltest/tufmtts.cpp
+++ b/source/test/intltest/tufmtts.cpp
@@ -1,5 +1,5 @@
/********************************************************************
- * Copyright (c) 2008-2014, International Business Machines Corporation and
+ * Copyright (c) 2008-2015, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@@ -11,9 +11,9 @@
#include "unicode/tmunit.h"
#include "unicode/tmutamt.h"
#include "unicode/tmutfmt.h"
-#include "tufmtts.h"
-#include "cmemory.h"
#include "unicode/ustring.h"
+#include "cmemory.h"
+#include "intltest.h"
//TODO: put as compilation flag
//#define TUFMTTS_DEBUG 1
@@ -22,16 +22,60 @@
#include <iostream>
#endif
-void TimeUnitTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) {
- if (exec) logln("TestSuite TimeUnitTest");
- switch (index) {
- TESTCASE(0, testBasic);
- TESTCASE(1, testAPI);
- TESTCASE(2, testGreekWithFallback);
- TESTCASE(3, testGreekWithSanitization);
- TESTCASE(4, test10219Plurals);
- default: name = ""; break;
+class TimeUnitTest : public IntlTest {
+ void runIndexedTest(int32_t index, UBool exec, const char* &name, char* /*par*/ ) {
+ if (exec) logln("TestSuite TimeUnitTest");
+ TESTCASE_AUTO_BEGIN;
+ TESTCASE_AUTO(testBasic);
+ TESTCASE_AUTO(testAPI);
+ TESTCASE_AUTO(testGreekWithFallback);
+ TESTCASE_AUTO(testGreekWithSanitization);
+ TESTCASE_AUTO(test10219Plurals);
+ TESTCASE_AUTO(TestBritishShortHourFallback);
+ TESTCASE_AUTO_END;
}
+
+public:
+ /**
+ * Performs basic tests
+ **/
+ void testBasic();
+
+ /**
+ * Performs API tests
+ **/
+ void testAPI();
+
+ /**
+ * Performs tests for Greek
+ * This tests that requests for short unit names correctly fall back
+ * to long unit names for a locale where the locale data does not
+ * provide short unit names. As of CLDR 1.9, Greek is one such language.
+ **/
+ void testGreekWithFallback();
+
+ /**
+ * Performs tests for Greek
+ * This tests that if the plural count listed in time unit format does not
+ * match those in the plural rules for the locale, those plural count in
+ * time unit format will be ingored and subsequently, fall back will kick in
+ * which is tested above.
+ * Without data sanitization, setNumberFormat() would crash.
+ * As of CLDR shiped in ICU4.8, Greek is one such language.
+ */
+ void testGreekWithSanitization();
+
+ /**
+ * Performs unit test for ticket 10219 making sure that plurals work
+ * correctly with rounding.
+ */
+ void test10219Plurals();
+
+ void TestBritishShortHourFallback();
+};
+
+extern IntlTest *createTimeUnitTest() {
+ return new TimeUnitTest();
}
// This function is more lenient than equals operator as it considers integer 3 hours and
@@ -469,4 +513,16 @@ void TimeUnitTest::test10219Plurals() {
}
}
+void TimeUnitTest::TestBritishShortHourFallback() {
+ // See ticket #11986 "incomplete fallback in MeasureFormat".
+ UErrorCode status = U_ZERO_ERROR;
+ Formattable oneHour(new TimeUnitAmount(1, TimeUnit::UTIMEUNIT_HOUR, status));
+ Locale en_GB("en_GB");
+ TimeUnitFormat formatter(en_GB, UTMUTFMT_ABBREVIATED_STYLE, status);
+ UnicodeString result;
+ formatter.format(oneHour, result, status);
+ assertSuccess("TestBritishShortHourFallback()", status);
+ assertEquals("TestBritishShortHourFallback()", UNICODE_STRING_SIMPLE("1 hr"), result);
+}
+
#endif
« no previous file with comments | « source/test/intltest/tufmtts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698