diff --git a/icu4c/source/test/intltest/itrbnf.cpp b/icu4c/source/test/intltest/itrbnf.cpp index 2dfdde39cbf..c4d047498c6 100644 --- a/icu4c/source/test/intltest/itrbnf.cpp +++ b/icu4c/source/test/intltest/itrbnf.cpp @@ -19,6 +19,8 @@ #include "unicode/ustring.h" #include "unicode/decimfmt.h" #include "unicode/udata.h" +#include "testutil.h" + //#include "llong.h" #include @@ -61,6 +63,7 @@ void IntlTestRBNF::runIndexedTest(int32_t index, UBool exec, const char* &name, TESTCASE(13, TestSmallValues); TESTCASE(14, TestLocalizations); TESTCASE(15, TestAllLocales); + TESTCASE(16, TestHebrewFraction); #else TESTCASE(0, TestRBNFDisabled); #endif @@ -72,23 +75,32 @@ void IntlTestRBNF::runIndexedTest(int32_t index, UBool exec, const char* &name, #if U_HAVE_RBNF +void IntlTestRBNF::TestHebrewFraction() { + // this is the expected output for 123.45, with no '<' in it. + UChar text[] = { + 0x05de, 0x05d0, 0x05d4,0x0020, + 0x05e2, 0x05e9, 0x05e8, 0x05d9, 0x05dd, 0x0020, + 0x05d5, 0x05e9, 0x05dc, 0x05d5, 0x05e9, 0x0020, + 0x05e0, 0x05e7, 0x05d5, 0x05d3, 0x05d4, 0x0020, + 0x05d0, 0x05e8, 0x05d1, 0x05e2, 0x05d9, 0x05dd, 0x0020, + 0x05d5, 0x05d7, 0x05de, 0x05e9, 0x0000, + }; + UErrorCode status = U_ZERO_ERROR; + RuleBasedNumberFormat* formatter = new RuleBasedNumberFormat(URBNF_SPELLOUT, "he_IW", status); + UnicodeString expected(text); + UnicodeString result; + formatter->format(123.450000, result); + if (result != expected) { + errln((UnicodeString)"expected '" + TestUtility::hex(expected) + "'\nbut got: '" + TestUtility::hex(result) + "'"); + } + delete formatter; +} + void IntlTestRBNF::TestAPI() { // This test goes through the APIs that were not tested before. // These tests are too small to have separate test classes/functions -#if 0 // debug - { - UErrorCode status = U_ZERO_ERROR; - RuleBasedNumberFormat* formatter = new RuleBasedNumberFormat(URBNF_SPELLOUT, "he_IW", status); - logln("Testing format(double)"); - UnicodeString result; - formatter->format(123.450000, result); - logln(result); - delete formatter; - } -#endif - UErrorCode status = U_ZERO_ERROR; RuleBasedNumberFormat* formatter = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getUS(), status); diff --git a/icu4c/source/test/intltest/itrbnf.h b/icu4c/source/test/intltest/itrbnf.h index 4a9699e525a..8d50b25cccc 100644 --- a/icu4c/source/test/intltest/itrbnf.h +++ b/icu4c/source/test/intltest/itrbnf.h @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * + * Copyright (C) 1996-2005, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -112,6 +112,11 @@ class IntlTestRBNF : public IntlTest { */ virtual void TestAllLocales(); + /** + * Test that hebrew fractions format without trailing '<' + */ + virtual void TestHebrewFraction(); + protected: virtual void doTest(RuleBasedNumberFormat* formatter, const char* testData[][2], UBool testParsing); virtual void doLenientParseTest(RuleBasedNumberFormat* formatter, const char* testData[][2]);