]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/itrbnf.cpp
ICU-57166.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / itrbnf.cpp
index ead78763b2f63df9ed93e8aeb5f54223030dfe33..ce731928a80648300df613fb95073ca2a2fdd7e7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
 /*
  *******************************************************************************
- * Copyright (C) 1996-2003, International Business Machines Corporation and    *
- * others. All Rights Reserved.                                                *
+ * Copyright (C) 1996-2016, International Business Machines Corporation and
+ * others. All Rights Reserved.
  *******************************************************************************
  */
 
  *******************************************************************************
  */
 
 #include "unicode/coleitr.h"
 #include "unicode/ures.h"
 #include "unicode/ustring.h"
 #include "unicode/coleitr.h"
 #include "unicode/ures.h"
 #include "unicode/ustring.h"
-//#include "llong.h"
+#include "unicode/decimfmt.h"
+#include "unicode/udata.h"
+#include "cmemory.h"
+#include "putilimp.h"
+#include "testutil.h"
 
 #include <string.h>
 
 
 #include <string.h>
 
@@ -33,7 +37,7 @@
         name = #test;                 \
         if (exec) {                   \
             logln(#test "---");       \
         name = #test;                 \
         if (exec) {                   \
             logln(#test "---");       \
-            logln((UnicodeString)""); \
+            logln();                  \
             test();                   \
         }                             \
         break
             test();                   \
         }                             \
         break
@@ -43,30 +47,101 @@ void IntlTestRBNF::runIndexedTest(int32_t index, UBool exec, const char* &name,
     if (exec) logln("TestSuite RuleBasedNumberFormat");
     switch (index) {
 #if U_HAVE_RBNF
     if (exec) logln("TestSuite RuleBasedNumberFormat");
     switch (index) {
 #if U_HAVE_RBNF
-      TESTCASE(0, TestEnglishSpellout);
-      TESTCASE(1, TestOrdinalAbbreviations);
-      TESTCASE(2, TestDurations);
-      TESTCASE(3, TestSpanishSpellout);
-      TESTCASE(4, TestFrenchSpellout);
-      TESTCASE(5, TestSwissFrenchSpellout);
-      TESTCASE(6, TestItalianSpellout);
-      TESTCASE(7, TestGermanSpellout);
-      TESTCASE(8, TestThaiSpellout);
-      TESTCASE(9, TestAPI);
-      TESTCASE(10, TestFractionalRuleSet);
-      TESTCASE(11, TestSwedishSpellout);
-         TESTCASE(12, TestBelgianFrenchSpellout);
+        TESTCASE(0, TestEnglishSpellout);
+        TESTCASE(1, TestOrdinalAbbreviations);
+        TESTCASE(2, TestDurations);
+        TESTCASE(3, TestSpanishSpellout);
+        TESTCASE(4, TestFrenchSpellout);
+        TESTCASE(5, TestSwissFrenchSpellout);
+        TESTCASE(6, TestItalianSpellout);
+        TESTCASE(7, TestGermanSpellout);
+        TESTCASE(8, TestThaiSpellout);
+        TESTCASE(9, TestAPI);
+        TESTCASE(10, TestFractionalRuleSet);
+        TESTCASE(11, TestSwedishSpellout);
+        TESTCASE(12, TestBelgianFrenchSpellout);
+        TESTCASE(13, TestSmallValues);
+        TESTCASE(14, TestLocalizations);
+        TESTCASE(15, TestAllLocales);
+        TESTCASE(16, TestHebrewFraction);
+        TESTCASE(17, TestPortugueseSpellout);
+        TESTCASE(18, TestMultiplierSubstitution);
+        TESTCASE(19, TestSetDecimalFormatSymbols);
+        TESTCASE(20, TestPluralRules);
+        TESTCASE(21, TestMultiplePluralRules);
+        TESTCASE(22, TestInfinityNaN);
+        TESTCASE(23, TestVariableDecimalPoint);
 #else
 #else
-      TESTCASE(0, TestRBNFDisabled);
+        TESTCASE(0, TestRBNFDisabled);
 #endif
     default:
 #endif
     default:
-      name = "";
-      break;
+        name = "";
+        break;
     }
 }
 
 #if U_HAVE_RBNF
 
     }
 }
 
 #if U_HAVE_RBNF
 
+void IntlTestRBNF::TestHebrewFraction() {
+
+    // this is the expected output for 123.45, with no '<' in it.
+    UChar text1[] = { 
+        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, 0x0020,
+        0x05d7, 0x05de, 0x05e9, 0x0000,
+    };
+    UChar text2[] = { 
+        0x05DE, 0x05D0, 0x05D4, 0x0020, 
+        0x05E2, 0x05E9, 0x05E8, 0x05D9, 0x05DD, 0x0020, 
+        0x05D5, 0x05E9, 0x05DC, 0x05D5, 0x05E9, 0x0020, 
+        0x05E0, 0x05E7, 0x05D5, 0x05D3, 0x05D4, 0x0020, 
+        0x05D0, 0x05E4, 0x05E1, 0x0020, 
+        0x05D0, 0x05E4, 0x05E1, 0x0020, 
+        0x05D0, 0x05E8, 0x05D1, 0x05E2, 0x0020, 
+        0x05D7, 0x05DE, 0x05E9, 0x0000,
+    };
+    UErrorCode status = U_ZERO_ERROR;
+    RuleBasedNumberFormat* formatter = new RuleBasedNumberFormat(URBNF_SPELLOUT, "he_IL", status);
+    if (status == U_MISSING_RESOURCE_ERROR || status == U_FILE_ACCESS_ERROR) {
+        errcheckln(status, "Failed in constructing RuleBasedNumberFormat - %s", u_errorName(status));
+        delete formatter;
+        return;
+    }
+    UnicodeString result;
+    Formattable parseResult;
+    ParsePosition pp(0);
+    {
+        UnicodeString expected(text1);
+        formatter->format(123.45, result);
+        if (result != expected) {
+            errln((UnicodeString)"expected '" + TestUtility::hex(expected) + "'\nbut got: '" + TestUtility::hex(result) + "'");
+        } else {
+//            formatter->parse(result, parseResult, pp);
+//            if (parseResult.getDouble() != 123.45) {
+//                errln("expected 123.45 but got: %g", parseResult.getDouble());
+//            }
+        }
+    }
+    {
+        UnicodeString expected(text2);
+        result.remove();
+        formatter->format(123.0045, result);
+        if (result != expected) {
+            errln((UnicodeString)"expected '" + TestUtility::hex(expected) + "'\nbut got: '" + TestUtility::hex(result) + "'");
+        } else {
+            pp.setIndex(0);
+//            formatter->parse(result, parseResult, pp);
+//            if (parseResult.getDouble() != 123.0045) {
+//                errln("expected 123.0045 but got: %g", parseResult.getDouble());
+//            }
+        }
+    }
+    delete formatter;
+}
+
 void 
 IntlTestRBNF::TestAPI() {
   // This test goes through the APIs that were not tested before. 
 void 
 IntlTestRBNF::TestAPI() {
   // This test goes through the APIs that were not tested before. 
@@ -75,6 +150,11 @@ IntlTestRBNF::TestAPI() {
   UErrorCode status = U_ZERO_ERROR;
   RuleBasedNumberFormat* formatter
       = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getUS(), status);
   UErrorCode status = U_ZERO_ERROR;
   RuleBasedNumberFormat* formatter
       = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getUS(), status);
+  if (status == U_MISSING_RESOURCE_ERROR || status == U_FILE_ACCESS_ERROR) {
+    dataerrln("Unable to create formatter. - %s", u_errorName(status));
+    delete formatter;
+    return;
+  }
 
   logln("RBNF API test starting");
   // test clone
 
   logln("RBNF API test starting");
   // test clone
@@ -104,12 +184,23 @@ IntlTestRBNF::TestAPI() {
   // test rule constructor
   {
     logln("Testing rule constructor");
   // test rule constructor
   {
     logln("Testing rule constructor");
-    UResourceBundle *en = ures_open(NULL, "en", &status);
+    LocalUResourceBundlePointer en(ures_open(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "rbnf", "en", &status));
     if(U_FAILURE(status)) {
       errln("Unable to access resource bundle with data!");
     } else {
       int32_t ruleLen = 0;
     if(U_FAILURE(status)) {
       errln("Unable to access resource bundle with data!");
     } else {
       int32_t ruleLen = 0;
-      const UChar *spelloutRules = ures_getStringByKey(en, "SpelloutRules", &ruleLen, &status);
+      int32_t len = 0;
+      LocalUResourceBundlePointer rbnfRules(ures_getByKey(en.getAlias(), "RBNFRules", NULL, &status));
+      LocalUResourceBundlePointer ruleSets(ures_getByKey(rbnfRules.getAlias(), "SpelloutRules", NULL, &status));
+      UnicodeString desc;
+      while (ures_hasNext(ruleSets.getAlias())) {
+           const UChar* currentString = ures_getNextString(ruleSets.getAlias(), &len, NULL, &status);
+           ruleLen += len;
+           desc.append(currentString);
+      }
+
+      const UChar *spelloutRules = desc.getTerminatedBuffer();
+
       if(U_FAILURE(status) || ruleLen == 0 || spelloutRules == NULL) {
         errln("Unable to access the rules string!");
       } else {
       if(U_FAILURE(status) || ruleLen == 0 || spelloutRules == NULL) {
         errln("Unable to access the rules string!");
       } else {
@@ -118,8 +209,13 @@ IntlTestRBNF::TestAPI() {
         if(!(ruleCtorResult == *formatter)) {
           errln("Formatter constructed from the original rules should be semantically equivalent to the original!");
         }
         if(!(ruleCtorResult == *formatter)) {
           errln("Formatter constructed from the original rules should be semantically equivalent to the original!");
         }
+        
+        // Jitterbug 4452, for coverage
+        RuleBasedNumberFormat nf(spelloutRules, (UnicodeString)"", Locale::getUS(), perror, status);
+        if(!(nf == *formatter)) {
+          errln("Formatter constructed from the original rules should be semantically equivalent to the original!");
+        }
       }
       }
-      ures_close(en);
     }
   }
 
     }
   }
 
@@ -145,6 +241,9 @@ IntlTestRBNF::TestAPI() {
   }
 
 #if !UCONFIG_NO_COLLATION
   }
 
 #if !UCONFIG_NO_COLLATION
+
+#define      NUMERIC_STRINGS_NOT_PARSEABLE   1   // ticket/8224
+
   // test ruleset names
   {
     logln("Testing getNumberOfRuleSetNames, getRuleSetName and format using rule set names");
   // test ruleset names
   {
     logln("Testing getNumberOfRuleSetNames, getRuleSetName and format using rule set names");
@@ -161,6 +260,10 @@ IntlTestRBNF::TestAPI() {
       FieldPosition pos1, pos2;
       UnicodeString intFormatResult, doubleFormatResult; 
       Formattable intParseResult, doubleParseResult;
       FieldPosition pos1, pos2;
       UnicodeString intFormatResult, doubleFormatResult; 
       Formattable intParseResult, doubleParseResult;
+#if NUMERIC_STRINGS_NOT_PARSEABLE
+      UBool parseDoubleNonLenientOK = TRUE;
+      UBool parseDoubleLenientOK = TRUE;
+#endif
 
       ruleSetName = formatter->getRuleSetName(i);
       log("Rule set name %i is ", i);
 
       ruleSetName = formatter->getRuleSetName(i);
       log("Rule set name %i is ", i);
@@ -174,18 +277,53 @@ IntlTestRBNF::TestAPI() {
       }
       logln(intFormatResult);
       logln(doubleFormatResult);
       }
       logln(intFormatResult);
       logln(doubleFormatResult);
+
+#if NUMERIC_STRINGS_NOT_PARSEABLE
+      // "spellout-numbering-year" ruleSet produces (above) a numeric string using:
+      //      "x.x: =#,###0.#=;"
+      //  which will not parse (below) - we believe this is CORRECT behavior, as found in ICU 4.0 (see ticket/8224).
+      //  Note this numeric string "89,3411.2" will not even parse with Lenient = TRUE because
+      //  the NumberFormat (used as last-resort) in NFSubstitution::doParse fails.
+      UnicodeString numberingYear = UNICODE_STRING_SIMPLE("spellout-numbering-year");
+
+      // "spellout-ordinal" and "spellout-ordinal-verbose" ruleSets produce (above) a numeric string using:
+      //      "x.x: =#,##0.#=;"  ->  "893,411.2"
+      //  which will not parse (below) with Lenient = FALSE, but does parse with Lenient = TRUE because
+      //  NFSubstitution::doParse will succeed when using NumberFormat as last-resort.
+      UnicodeString ordinal = UNICODE_STRING_SIMPLE("spellout-ordinal");
+
+      //  RuleSets other than spellout-numbering-year and spellout-ordinalXXX produce fully spelled out text above
+      //  which is fully parseable.
+      parseDoubleLenientOK = ( ruleSetName.indexOf(numberingYear) == -1 );
+      parseDoubleNonLenientOK = ( ruleSetName.indexOf(numberingYear) == -1 && ruleSetName.indexOf(ordinal) == -1 );
+#endif
+
       formatter->setLenient(TRUE);
       formatter->parse(intFormatResult, intParseResult, status);
       formatter->parse(doubleFormatResult, doubleParseResult, status);
 
       logln("Parse results for lenient = TRUE, %i, %f", intParseResult.getLong(), doubleParseResult.getDouble());
 
       formatter->setLenient(TRUE);
       formatter->parse(intFormatResult, intParseResult, status);
       formatter->parse(doubleFormatResult, doubleParseResult, status);
 
       logln("Parse results for lenient = TRUE, %i, %f", intParseResult.getLong(), doubleParseResult.getDouble());
 
+#if NUMERIC_STRINGS_NOT_PARSEABLE
+      if((!parseDoubleLenientOK) && (status == U_INVALID_FORMAT_ERROR)) {
+        status = U_USING_FALLBACK_WARNING;
+        logln("Clearing expected U_INVALID_FORMAT_ERROR during parsing");
+      }
+#endif
+
       formatter->setLenient(FALSE);
       formatter->parse(intFormatResult, intParseResult, status);
       formatter->parse(doubleFormatResult, doubleParseResult, status);
 
       logln("Parse results for lenient = FALSE, %i, %f", intParseResult.getLong(), doubleParseResult.getDouble());
 
       formatter->setLenient(FALSE);
       formatter->parse(intFormatResult, intParseResult, status);
       formatter->parse(doubleFormatResult, doubleParseResult, status);
 
       logln("Parse results for lenient = FALSE, %i, %f", intParseResult.getLong(), doubleParseResult.getDouble());
 
+#if NUMERIC_STRINGS_NOT_PARSEABLE
+      if((!parseDoubleNonLenientOK) && (status == U_INVALID_FORMAT_ERROR)) {
+        status = U_USING_FALLBACK_WARNING;
+        logln("Clearing expected U_INVALID_FORMAT_ERROR during parsing");
+      }
+#endif
+
       if(U_FAILURE(status)) {
         errln("Error during parsing");
       }
       if(U_FAILURE(status)) {
         errln("Error during parsing");
       }
@@ -226,12 +364,96 @@ IntlTestRBNF::TestAPI() {
       logln("Formatted 4, expected " + expected + " got " + result);
   }
 
       logln("Formatted 4, expected " + expected + " got " + result);
   }
 
+  result.remove();
+  FieldPosition pos;
+  formatter->format((int64_t)4, result, pos, status = U_ZERO_ERROR);
+  if(result != expected) {
+      errln("Formatted 4 int64_t, expected " + expected + " got " + result);
+  } else {
+      logln("Formatted 4 int64_t, expected " + expected + " got " + result);
+  }
+
+  //Jitterbug 4452, for coverage
+  result.remove();
+  FieldPosition pos2;
+  formatter->format((int64_t)4, formatter->getRuleSetName(0), result, pos2, status = U_ZERO_ERROR);
+  if(result != expected) {
+      errln("Formatted 4 int64_t, expected " + expected + " got " + result);
+  } else {
+      logln("Formatted 4 int64_t, expected " + expected + " got " + result);
+  }
 
   // clean up
   logln("Cleaning up");
   delete formatter;
 }
 
 
   // clean up
   logln("Cleaning up");
   delete formatter;
 }
 
+/**
+ * Perform a simple spot check on the parsing going into an infinite loop for alternate rules.
+ */
+void IntlTestRBNF::TestMultiplePluralRules() {
+    // This is trying to model the feminine form, but don't worry about the details too much.
+    // We're trying to test the plural rules where there are different prefixes.
+    UnicodeString rules("%spellout-cardinal-feminine-genitive:"
+                "0: zero;"
+                "1: ono;"
+                "2: two;"
+                "1000: << $(cardinal,one{thousand}few{thousanF}other{thousanO})$[ >>];"
+                "%spellout-cardinal-feminine:"
+                "x.x: [<< $(cardinal,one{singleton}other{plurality})$ ]>%%fractions>;"
+                "0: zero;"
+                "1: one;"
+                "2: two;"
+                "1000: << $(cardinal,one{thousand}few{thousanF}other{thousanO})$[ >>];"
+                "%%fractions:"
+                "10: <%spellout-cardinal-feminine< $(cardinal,one{oneth}other{tenth})$;"
+                "100: <%spellout-cardinal-feminine< $(cardinal,one{1hundredth}other{hundredth})$;");
+    UErrorCode status = U_ZERO_ERROR;
+    UParseError pError;
+    RuleBasedNumberFormat formatter(rules, Locale("ru"), pError, status);
+    Formattable result;
+    UnicodeString resultStr;
+    FieldPosition pos;
+
+    if (U_FAILURE(status)) {
+        dataerrln("Unable to create formatter - %s", u_errorName(status));
+        return;
+    }
+
+    formatter.parse(formatter.format(1000.0, resultStr, pos, status), result, status);
+    if (1000 != result.getLong() || resultStr != UNICODE_STRING_SIMPLE("one thousand")) {
+        errln("RuleBasedNumberFormat did not return the correct value. Got: %d", result.getLong());
+        errln(resultStr);
+    }
+    resultStr.remove();
+    formatter.parse(formatter.format(1000.0, UnicodeString("%spellout-cardinal-feminine-genitive"), resultStr, pos, status), result, status);
+    if (1000 != result.getLong() || resultStr != UNICODE_STRING_SIMPLE("ono thousand")) {
+        errln("RuleBasedNumberFormat(cardinal-feminine-genitive) did not return the correct value. Got: %d", result.getLong());
+        errln(resultStr);
+    }
+    resultStr.remove();
+    formatter.parse(formatter.format(1000.0, UnicodeString("%spellout-cardinal-feminine"), resultStr, pos, status), result, status);
+    if (1000 != result.getLong() || resultStr != UNICODE_STRING_SIMPLE("one thousand")) {
+        errln("RuleBasedNumberFormat(spellout-cardinal-feminine) did not return the correct value. Got: %d", result.getLong());
+        errln(resultStr);
+    }
+    static const char* const testData[][2] = {
+        { "0", "zero" },
+        { "1", "one" },
+        { "2", "two" },
+        { "0.1", "one oneth" },
+        { "0.2", "two tenth" },
+        { "1.1", "one singleton one oneth" },
+        { "1.2", "one singleton two tenth" },
+        { "2.1", "two plurality one oneth" },
+        { "2.2", "two plurality two tenth" },
+        { "0.01", "one 1hundredth" },
+        { "0.02", "two hundredth" },
+        { NULL, NULL }
+    };
+    doTest(&formatter, testData, TRUE);
+}
+
 void IntlTestRBNF::TestFractionalRuleSet()
 {
     UnicodeString fracRules(
 void IntlTestRBNF::TestFractionalRuleSet()
 {
     UnicodeString fracRules(
@@ -289,9 +511,9 @@ void IntlTestRBNF::TestFractionalRuleSet()
     UParseError perror;
     RuleBasedNumberFormat formatter(fracRules, Locale::getEnglish(), perror, status);
     if (U_FAILURE(status)) {
     UParseError perror;
     RuleBasedNumberFormat formatter(fracRules, Locale::getEnglish(), perror, status);
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "0", "0" },
             { ".1", "1/10" },
             { ".11", "1/9" },
             { "0", "0" },
             { ".1", "1/10" },
             { ".11", "1/9" },
@@ -317,7 +539,7 @@ void IntlTestRBNF::TestFractionalRuleSet()
             { "1.2856", "1 2/7" },
             { NULL, NULL }
         };
             { "1.2856", "1 2/7" },
             { NULL, NULL }
         };
-       doTest(&formatter, testData, FALSE); // exact values aren't parsable from fractions
+        doTest(&formatter, testData, FALSE); // exact values aren't parsable from fractions
     }
 }
 
     }
 }
 
@@ -780,7 +1002,7 @@ void IntlTestRBNF::TestLLong()
             &NEG_TWO_TO_32X5, &TWO_TO_32, &NEG_FIVE
         };
         const int TUPLE_WIDTH = 3;
             &NEG_TWO_TO_32X5, &TWO_TO_32, &NEG_FIVE
         };
         const int TUPLE_WIDTH = 3;
-        const int TUPLE_COUNT = (int)(sizeof(tuples)/sizeof(tuples[0]))/TUPLE_WIDTH;
+        const int TUPLE_COUNT = UPRV_LENGTHOF(tuples)/TUPLE_WIDTH;
         for (int i = 0; i < TUPLE_COUNT; ++i) {
             const llong lhs = *tuples[i*TUPLE_WIDTH+0];
             const llong rhs = *tuples[i*TUPLE_WIDTH+1];
         for (int i = 0; i < TUPLE_COUNT; ++i) {
             const llong lhs = *tuples[i*TUPLE_WIDTH+0];
             const llong rhs = *tuples[i*TUPLE_WIDTH+1];
@@ -860,7 +1082,7 @@ void IntlTestRBNF::TestLLong()
             &BIG_FIVEp1, &FIVE, &ONE
         };
         const int TUPLE_WIDTH = 3;
             &BIG_FIVEp1, &FIVE, &ONE
         };
         const int TUPLE_WIDTH = 3;
-        const int TUPLE_COUNT = (int)(sizeof(tuples)/sizeof(tuples[0]))/TUPLE_WIDTH;
+        const int TUPLE_COUNT = UPRV_LENGTHOF(tuples)/TUPLE_WIDTH;
         for (int i = 0; i < TUPLE_COUNT; ++i) {
             const llong lhs = *tuples[i*TUPLE_WIDTH+0];
             const llong rhs = *tuples[i*TUPLE_WIDTH+1];
         for (int i = 0; i < TUPLE_COUNT; ++i) {
             const llong lhs = *tuples[i*TUPLE_WIDTH+0];
             const llong rhs = *tuples[i*TUPLE_WIDTH+1];
@@ -956,11 +1178,10 @@ IntlTestRBNF::TestEnglishSpellout()
     UErrorCode status = U_ZERO_ERROR;
     RuleBasedNumberFormat* formatter
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getUS(), status);
     UErrorCode status = U_ZERO_ERROR;
     RuleBasedNumberFormat* formatter
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getUS(), status);
-
     if (U_FAILURE(status)) {
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "1", "one" },
             { "2", "two" },
             { "15", "fifteen" },
             { "1", "one" },
             { "2", "two" },
             { "15", "fifteen" },
@@ -969,18 +1190,18 @@ IntlTestRBNF::TestEnglishSpellout()
             { "73", "seventy-three" },
             { "88", "eighty-eight" },
             { "100", "one hundred" },
             { "73", "seventy-three" },
             { "88", "eighty-eight" },
             { "100", "one hundred" },
-            { "106", "one hundred and six" },
-            { "127", "one hundred and twenty-seven" },
+            { "106", "one hundred six" },
+            { "127", "one hundred twenty-seven" },
             { "200", "two hundred" },
             { "200", "two hundred" },
-            { "579", "five hundred and seventy-nine" },
+            { "579", "five hundred seventy-nine" },
             { "1,000", "one thousand" },
             { "2,000", "two thousand" },
             { "1,000", "one thousand" },
             { "2,000", "two thousand" },
-            { "3,004", "three thousand and four" },
-            { "4,567", "four thousand five hundred and sixty-seven" },
-            { "15,943", "fifteen thousand nine hundred and forty-three" },
-            { "2,345,678", "two million, three hundred and forty-five thousand, six hundred and seventy-eight" },
+            { "3,004", "three thousand four" },
+            { "4,567", "four thousand five hundred sixty-seven" },
+            { "15,943", "fifteen thousand nine hundred forty-three" },
+            { "2,345,678", "two million three hundred forty-five thousand six hundred seventy-eight" },
             { "-36", "minus thirty-six" },
             { "-36", "minus thirty-six" },
-            { "234.567", "two hundred and thirty-four point five six seven" },
+            { "234.567", "two hundred thirty-four point five six seven" },
             { NULL, NULL}
         };
 
             { NULL, NULL}
         };
 
@@ -1011,9 +1232,9 @@ IntlTestRBNF::TestOrdinalAbbreviations()
         = new RuleBasedNumberFormat(URBNF_ORDINAL, Locale::getUS(), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_ORDINAL, Locale::getUS(), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "1", "1st" },
             { "2", "2nd" },
             { "3", "3rd" },
             { "1", "1st" },
             { "2", "2nd" },
             { "3", "3rd" },
@@ -1047,9 +1268,9 @@ IntlTestRBNF::TestDurations()
         = new RuleBasedNumberFormat(URBNF_DURATION, Locale::getUS(), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_DURATION, Locale::getUS(), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "3,600", "1:00:00" },     //move me and I fail
             { "0", "0 sec." },
             { "1", "1 sec." },
             { "3,600", "1:00:00" },     //move me and I fail
             { "0", "0 sec." },
             { "1", "1 sec." },
@@ -1086,9 +1307,9 @@ IntlTestRBNF::TestSpanishSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("es", "ES", ""), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("es", "ES", ""), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "1", "uno" },
             { "6", "seis" },
             { "16", "diecis\\u00e9is" },
             { "1", "uno" },
             { "6", "seis" },
             { "16", "diecis\\u00e9is" },
@@ -1107,9 +1328,9 @@ IntlTestRBNF::TestSpanishSpellout()
             { "3,004", "tres mil cuatro" },
             { "4,567", "cuatro mil quinientos sesenta y siete" },
             { "15,943", "quince mil novecientos cuarenta y tres" },
             { "3,004", "tres mil cuatro" },
             { "4,567", "cuatro mil quinientos sesenta y siete" },
             { "15,943", "quince mil novecientos cuarenta y tres" },
-            { "2,345,678", "dos mill\\u00f3n trescientos cuarenta y cinco mil seiscientos setenta y ocho"},
+            { "2,345,678", "dos millones trescientos cuarenta y cinco mil seiscientos setenta y ocho"},
             { "-36", "menos treinta y seis" },
             { "-36", "menos treinta y seis" },
-            { "234.567", "doscientos treinta y cuatro punto cinco seis siete" },
+            { "234.567", "doscientos treinta y cuatro coma cinco seis siete" },
             { NULL, NULL}
         };
         
             { NULL, NULL}
         };
         
@@ -1126,9 +1347,9 @@ IntlTestRBNF::TestFrenchSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getFrance(), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getFrance(), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "1", "un" },
             { "15", "quinze" },
             { "20", "vingt" },
             { "1", "un" },
             { "15", "quinze" },
             { "20", "vingt" },
@@ -1136,7 +1357,7 @@ IntlTestRBNF::TestFrenchSpellout()
             { "23", "vingt-trois" },
             { "62", "soixante-deux" },
             { "70", "soixante-dix" },
             { "23", "vingt-trois" },
             { "62", "soixante-deux" },
             { "70", "soixante-dix" },
-            { "71", "soixante et onze" },
+            { "71", "soixante-et-onze" },
             { "73", "soixante-treize" },
             { "80", "quatre-vingts" },
             { "88", "quatre-vingt-huit" },
             { "73", "soixante-treize" },
             { "80", "quatre-vingts" },
             { "88", "quatre-vingt-huit" },
@@ -1144,17 +1365,17 @@ IntlTestRBNF::TestFrenchSpellout()
             { "106", "cent six" },
             { "127", "cent vingt-sept" },
             { "200", "deux cents" },
             { "106", "cent six" },
             { "127", "cent vingt-sept" },
             { "200", "deux cents" },
-            { "579", "cinq cents soixante-dix-neuf" },
+            { "579", "cinq cent soixante-dix-neuf" },
             { "1,000", "mille" },
             { "1,000", "mille" },
-            { "1,123", "onze cents vingt-trois" },
-            { "1,594", "mille cinq cents quatre-vingt-quatorze" },
+            { "1,123", "mille cent vingt-trois" },
+            { "1,594", "mille cinq cent quatre-vingt-quatorze" },
             { "2,000", "deux mille" },
             { "3,004", "trois mille quatre" },
             { "2,000", "deux mille" },
             { "3,004", "trois mille quatre" },
-            { "4,567", "quatre mille cinq cents soixante-sept" },
-            { "15,943", "quinze mille neuf cents quarante-trois" },
-            { "2,345,678", "deux million trois cents quarante-cinq mille six cents soixante-dix-huit" },
+            { "4,567", "quatre mille cinq cent soixante-sept" },
+            { "15,943", "quinze mille neuf cent quarante-trois" },
+            { "2,345,678", "deux millions trois cent quarante-cinq mille six cent soixante-dix-huit" },
             { "-36", "moins trente-six" },
             { "-36", "moins trente-six" },
-            { "234.567", "deux cents trente-quatre virgule cinq six sept" },
+            { "234.567", "deux cent trente-quatre virgule cinq six sept" },
             { NULL, NULL}
         };
         
             { NULL, NULL}
         };
         
@@ -1163,8 +1384,8 @@ IntlTestRBNF::TestFrenchSpellout()
 #if !UCONFIG_NO_COLLATION
         formatter->setLenient(TRUE);
         static const char* lpTestData[][2] = {
 #if !UCONFIG_NO_COLLATION
         formatter->setLenient(TRUE);
         static const char* lpTestData[][2] = {
-            { "trente-un", "31" },
-            { "un cents quatre vingt dix huit", "198" },
+            { "trente-et-un", "31" },
+            { "un cent quatre vingt dix huit", "198" },
             { NULL, NULL}
         };
         doLenientParseTest(formatter, lpTestData);
             { NULL, NULL}
         };
         doLenientParseTest(formatter, lpTestData);
@@ -1173,34 +1394,34 @@ IntlTestRBNF::TestFrenchSpellout()
     delete formatter;
 }
 
     delete formatter;
 }
 
-static const char* swissFrenchTestData[][2] = {
-       { "1", "un" },
-       { "15", "quinze" },
-       { "20", "vingt" },
-       { "21", "vingt-et-un" },
-       { "23", "vingt-trois" },
-       { "62", "soixante-deux" },
-       { "70", "septante" },
-       { "71", "septante-et-un" },
-       { "73", "septante-trois" },
-       { "80", "huitante" },
-       { "88", "huitante-huit" },
-       { "100", "cent" },
-       { "106", "cent six" },
-       { "127", "cent vingt-sept" },
-       { "200", "deux cents" },
-       { "579", "cinq cents septante-neuf" },
-       { "1,000", "mille" },
-       { "1,123", "onze cents vingt-trois" },
-       { "1,594", "mille cinq cents nonante-quatre" },
-       { "2,000", "deux mille" },
-       { "3,004", "trois mille quatre" },
-       { "4,567", "quatre mille cinq cents soixante-sept" },
-       { "15,943", "quinze mille neuf cents quarante-trois" },
-       { "2,345,678", "deux million trois cents quarante-cinq mille six cents septante-huit" },
-       { "-36", "moins trente-six" },
-       { "234.567", "deux cents trente-quatre virgule cinq six sept" },
-       { NULL, NULL}
+static const char* const swissFrenchTestData[][2] = {
+    { "1", "un" },
+    { "15", "quinze" },
+    { "20", "vingt" },
+    { "21", "vingt-et-un" },
+    { "23", "vingt-trois" },
+    { "62", "soixante-deux" },
+    { "70", "septante" },
+    { "71", "septante-et-un" },
+    { "73", "septante-trois" },
+    { "80", "huitante" },
+    { "88", "huitante-huit" },
+    { "100", "cent" },
+    { "106", "cent six" },
+    { "127", "cent vingt-sept" },
+    { "200", "deux cents" },
+    { "579", "cinq cent septante-neuf" },
+    { "1,000", "mille" },
+    { "1,123", "mille cent vingt-trois" },
+    { "1,594", "mille cinq cent nonante-quatre" },
+    { "2,000", "deux mille" },
+    { "3,004", "trois mille quatre" },
+    { "4,567", "quatre mille cinq cent soixante-sept" },
+    { "15,943", "quinze mille neuf cent quarante-trois" },
+    { "2,345,678", "deux millions trois cent quarante-cinq mille six cent septante-huit" },
+    { "-36", "moins trente-six" },
+    { "234.567", "deux cent trente-quatre virgule cinq six sept" },
+    { NULL, NULL}
 };
 
 void 
 };
 
 void 
@@ -1211,13 +1432,47 @@ IntlTestRBNF::TestSwissFrenchSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("fr", "CH", ""), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("fr", "CH", ""), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
         doTest(formatter, swissFrenchTestData, TRUE);
     }
     delete formatter;
 }
 
     } else {
         doTest(formatter, swissFrenchTestData, TRUE);
     }
     delete formatter;
 }
 
+static const char* const belgianFrenchTestData[][2] = {
+    { "1", "un" },
+    { "15", "quinze" },
+    { "20", "vingt" },
+    { "21", "vingt-et-un" },
+    { "23", "vingt-trois" },
+    { "62", "soixante-deux" },
+    { "70", "septante" },
+    { "71", "septante-et-un" },
+    { "73", "septante-trois" },
+    { "80", "quatre-vingts" },
+    { "88", "quatre-vingt huit" },
+    { "90", "nonante" },
+    { "91", "nonante-et-un" },
+    { "95", "nonante-cinq" },
+    { "100", "cent" },
+    { "106", "cent six" },
+    { "127", "cent vingt-sept" },
+    { "200", "deux cents" },
+    { "579", "cinq cent septante-neuf" },
+    { "1,000", "mille" },
+    { "1,123", "mille cent vingt-trois" },
+    { "1,594", "mille cinq cent nonante-quatre" },
+    { "2,000", "deux mille" },
+    { "3,004", "trois mille quatre" },
+    { "4,567", "quatre mille cinq cent soixante-sept" },
+    { "15,943", "quinze mille neuf cent quarante-trois" },
+    { "2,345,678", "deux millions trois cent quarante-cinq mille six cent septante-huit" },
+    { "-36", "moins trente-six" },
+    { "234.567", "deux cent trente-quatre virgule cinq six sept" },
+    { NULL, NULL}
+};
+
+
 void 
 IntlTestRBNF::TestBelgianFrenchSpellout() 
 {
 void 
 IntlTestRBNF::TestBelgianFrenchSpellout() 
 {
@@ -1226,11 +1481,11 @@ IntlTestRBNF::TestBelgianFrenchSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("fr", "BE", ""), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("fr", "BE", ""), status);
     
     if (U_FAILURE(status)) {
-               fprintf(stderr, "rbnf status: %d (%x)\n", status, status);
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "rbnf status: 0x%x (%s)\n", status, u_errorName(status));
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-               // Belgian french should match Swiss french.
-        doTest(formatter, swissFrenchTestData, TRUE);
+        // Belgian french should match Swiss french.
+        doTest(formatter, belgianFrenchTestData, TRUE);
     }
     delete formatter;
 }
     }
     delete formatter;
 }
@@ -1243,29 +1498,31 @@ IntlTestRBNF::TestItalianSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getItalian(), status);
 
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getItalian(), status);
 
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "1", "uno" },
             { "15", "quindici" },
             { "20", "venti" },
             { "1", "uno" },
             { "15", "quindici" },
             { "20", "venti" },
-            { "23", "ventitre" },
-            { "73", "settantatre" },
-            { "88", "ottantotto" },
+            { "23", "venti\\u00ADtr\\u00E9" },
+            { "73", "settanta\\u00ADtr\\u00E9" },
+            { "88", "ottant\\u00ADotto" },
             { "100", "cento" },
             { "100", "cento" },
-            { "106", "centosei" },
-            { "108", "centotto" },
-            { "127", "centoventisette" },
-            { "181", "centottantuno" },
-            { "200", "duecento" },
-            { "579", "cinquecentosettantanove" },
+            { "101", "cento\\u00ADuno" },
+            { "103", "cento\\u00ADtr\\u00E9" },
+            { "106", "cento\\u00ADsei" },
+            { "108", "cent\\u00ADotto" },
+            { "127", "cento\\u00ADventi\\u00ADsette" },
+            { "181", "cent\\u00ADottant\\u00ADuno" },
+            { "200", "due\\u00ADcento" },
+            { "579", "cinque\\u00ADcento\\u00ADsettanta\\u00ADnove" },
             { "1,000", "mille" },
             { "1,000", "mille" },
-            { "2,000", "duemila" },
-            { "3,004", "tremilaquattro" },
-            { "4,567", "quattromilacinquecentosessantasette" },
-            { "15,943", "quindicimilanovecentoquarantatre" },
-            { "-36", "meno trentisei" },
-            { "234.567", "duecentotrentiquattro virgola cinque sei sette" },
+            { "2,000", "due\\u00ADmila" },
+            { "3,004", "tre\\u00ADmila\\u00ADquattro" },
+            { "4,567", "quattro\\u00ADmila\\u00ADcinque\\u00ADcento\\u00ADsessanta\\u00ADsette" },
+            { "15,943", "quindici\\u00ADmila\\u00ADnove\\u00ADcento\\u00ADquaranta\\u00ADtr\\u00E9" },
+            { "-36", "meno trenta\\u00ADsei" },
+            { "234.567", "due\\u00ADcento\\u00ADtrenta\\u00ADquattro virgola cinque sei sette" },
             { NULL, NULL}
         };
         
             { NULL, NULL}
         };
         
@@ -1274,6 +1531,44 @@ IntlTestRBNF::TestItalianSpellout()
     delete formatter;
 }
 
     delete formatter;
 }
 
+void 
+IntlTestRBNF::TestPortugueseSpellout() 
+{
+    UErrorCode status = U_ZERO_ERROR;
+    RuleBasedNumberFormat* formatter
+        = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("pt","BR",""), status);
+
+    if (U_FAILURE(status)) {
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
+    } else {
+        static const char* const testData[][2] = {
+            { "1", "um" },
+            { "15", "quinze" },
+            { "20", "vinte" },
+            { "23", "vinte e tr\\u00EAs" },
+            { "73", "setenta e tr\\u00EAs" },
+            { "88", "oitenta e oito" },
+            { "100", "cem" },
+            { "106", "cento e seis" },
+            { "108", "cento e oito" },
+            { "127", "cento e vinte e sete" },
+            { "181", "cento e oitenta e um" },
+            { "200", "duzentos" },
+            { "579", "quinhentos e setenta e nove" },
+            { "1,000", "mil" },
+            { "2,000", "dois mil" },
+            { "3,004", "tr\\u00EAs mil e quatro" },
+            { "4,567", "quatro mil e quinhentos e sessenta e sete" },
+            { "15,943", "quinze mil e novecentos e quarenta e tr\\u00EAs" },
+            { "-36", "menos trinta e seis" },
+            { "234.567", "duzentos e trinta e quatro v\\u00EDrgula cinco seis sete" },
+            { NULL, NULL}
+        };
+        
+        doTest(formatter, testData, TRUE);
+    }
+    delete formatter;
+}
 void 
 IntlTestRBNF::TestGermanSpellout() 
 {
 void 
 IntlTestRBNF::TestGermanSpellout() 
 {
@@ -1282,26 +1577,26 @@ IntlTestRBNF::TestGermanSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getGermany(), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale::getGermany(), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "1", "eins" },
             { "15", "f\\u00fcnfzehn" },
             { "20", "zwanzig" },
             { "1", "eins" },
             { "15", "f\\u00fcnfzehn" },
             { "20", "zwanzig" },
-            { "23", "dreiundzwanzig" },
-            { "73", "dreiundsiebzig" },
-            { "88", "achtundachtzig" },
-            { "100", "hundert" },
-            { "106", "hundertsechs" },
-            { "127", "hundertsiebenundzwanzig" },
-            { "200", "zweihundert" },
-            { "579", "f\\u00fcnfhundertneunundsiebzig" },
-            { "1,000", "tausend" },
-            { "2,000", "zweitausend" },
-            { "3,004", "dreitausendvier" },
-            { "4,567", "viertausendf\\u00fcnfhundertsiebenundsechzig" },
-            { "15,943", "f\\u00fcnfzehntausendneunhundertdreiundvierzig" },
-            { "2,345,678", "zwei Millionen dreihundertf\\u00fcnfundvierzigtausendsechshundertachtundsiebzig" },
+            { "23", "drei\\u00ADund\\u00ADzwanzig" },
+            { "73", "drei\\u00ADund\\u00ADsiebzig" },
+            { "88", "acht\\u00ADund\\u00ADachtzig" },
+            { "100", "ein\\u00ADhundert" },
+            { "106", "ein\\u00ADhundert\\u00ADsechs" },
+            { "127", "ein\\u00ADhundert\\u00ADsieben\\u00ADund\\u00ADzwanzig" },
+            { "200", "zwei\\u00ADhundert" },
+            { "579", "f\\u00fcnf\\u00ADhundert\\u00ADneun\\u00ADund\\u00ADsiebzig" },
+            { "1,000", "ein\\u00ADtausend" },
+            { "2,000", "zwei\\u00ADtausend" },
+            { "3,004", "drei\\u00ADtausend\\u00ADvier" },
+            { "4,567", "vier\\u00ADtausend\\u00ADf\\u00fcnf\\u00ADhundert\\u00ADsieben\\u00ADund\\u00ADsechzig" },
+            { "15,943", "f\\u00fcnfzehn\\u00ADtausend\\u00ADneun\\u00ADhundert\\u00ADdrei\\u00ADund\\u00ADvierzig" },
+            { "2,345,678", "zwei Millionen drei\\u00ADhundert\\u00ADf\\u00fcnf\\u00ADund\\u00ADvierzig\\u00ADtausend\\u00ADsechs\\u00ADhundert\\u00ADacht\\u00ADund\\u00ADsiebzig" },
             { NULL, NULL}
         };
         
             { NULL, NULL}
         };
         
@@ -1327,16 +1622,16 @@ IntlTestRBNF::TestThaiSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("th"), status);
     
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("th"), status);
     
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
     } else {
-        static const char* testData[][2] = {
+        static const char* const testData[][2] = {
             { "0", "\\u0e28\\u0e39\\u0e19\\u0e22\\u0e4c" },
             { "1", "\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07" },
             { "10", "\\u0e2a\\u0e34\\u0e1a" },
             { "0", "\\u0e28\\u0e39\\u0e19\\u0e22\\u0e4c" },
             { "1", "\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07" },
             { "10", "\\u0e2a\\u0e34\\u0e1a" },
-            { "11", "\\u0e2a\\u0e34\\u0e1a\\u0e40\\u0e2d\\u0e47\\u0e14" },
-            { "21", "\\u0e22\\u0e35\\u0e48\\u0e2a\\u0e34\\u0e1a\\u0e40\\u0e2d\\u0e47\\u0e14" },
-            { "101", "\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07\\u0e23\\u0e49\\u0e2d\\u0e22\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07" },
-            { "1.234", "\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07\\u0e08\\u0e38\\u0e14\\u0e2a\\u0e2d\\u0e07\\u0e2a\\u0e32\\u0e21\\u0e2a\\u0e35\\u0e48" },
+            { "11", "\\u0e2a\\u0e34\\u0e1a\\u200b\\u0e40\\u0e2d\\u0e47\\u0e14" },
+            { "21", "\\u0e22\\u0e35\\u0e48\\u200b\\u0e2a\\u0e34\\u0e1a\\u200b\\u0e40\\u0e2d\\u0e47\\u0e14" },
+            { "101", "\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07\\u200b\\u0e23\\u0e49\\u0e2d\\u0e22\\u200b\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07" },
+            { "1.234", "\\u0e2b\\u0e19\\u0e36\\u0e48\\u0e07\\u200b\\u0e08\\u0e38\\u0e14\\u200b\\u0e2a\\u0e2d\\u0e07\\u0e2a\\u0e32\\u0e21\\u0e2a\\u0e35\\u0e48" },
             { NULL, NULL}
         };
         
             { NULL, NULL}
         };
         
@@ -1353,63 +1648,64 @@ IntlTestRBNF::TestSwedishSpellout()
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("sv"), status);
 
     if (U_FAILURE(status)) {
         = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("sv"), status);
 
     if (U_FAILURE(status)) {
-        errln("FAIL: could not construct formatter");
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
     } else {
         static const char* testDataDefault[][2] = {
     } else {
         static const char* testDataDefault[][2] = {
-            { "101", "etthundra\\u00aden" },
-            { "123", "etthundra\\u00adtjugotre" },
-            { "1,001", "ettusen en" },
-            { "1,100", "ettusen etthundra" },
-            { "1,101", "ettusen etthundra\\u00aden" },
-            { "1,234", "ettusen tv\\u00e5hundra\\u00adtrettiofyra" },
-            { "10,001", "tio\\u00adtusen en" },
+            { "101", "ett\\u00adhundra\\u00adett" },
+            { "123", "ett\\u00adhundra\\u00adtjugo\\u00adtre" },
+            { "1,001", "et\\u00adtusen ett" },
+            { "1,100", "et\\u00adtusen ett\\u00adhundra" },
+            { "1,101", "et\\u00adtusen ett\\u00adhundra\\u00adett" },
+            { "1,234", "et\\u00adtusen tv\\u00e5\\u00adhundra\\u00adtrettio\\u00adfyra" },
+            { "10,001", "tio\\u00adtusen ett" },
             { "11,000", "elva\\u00adtusen" },
             { "12,000", "tolv\\u00adtusen" },
             { "20,000", "tjugo\\u00adtusen" },
             { "11,000", "elva\\u00adtusen" },
             { "12,000", "tolv\\u00adtusen" },
             { "20,000", "tjugo\\u00adtusen" },
-            { "21,000", "tjugoen\\u00adtusen" },
-            { "21,001", "tjugoen\\u00adtusen en" },
-            { "200,000", "tv\\u00e5hundra\\u00adtusen" },
-            { "201,000", "tv\\u00e5hundra\\u00aden\\u00adtusen" },
-            { "200,200", "tv\\u00e5hundra\\u00adtusen tv\\u00e5hundra" },
+            { "21,000", "tjugo\\u00adet\\u00adtusen" },
+            { "21,001", "tjugo\\u00adet\\u00adtusen ett" },
+            { "200,000", "tv\\u00e5\\u00adhundra\\u00adtusen" },
+            { "201,000", "tv\\u00e5\\u00adhundra\\u00adet\\u00adtusen" },
+            { "200,200", "tv\\u00e5\\u00adhundra\\u00adtusen tv\\u00e5\\u00adhundra" },
             { "2,002,000", "tv\\u00e5 miljoner tv\\u00e5\\u00adtusen" },
             { "2,002,000", "tv\\u00e5 miljoner tv\\u00e5\\u00adtusen" },
-            { "12,345,678", "tolv miljoner trehundra\\u00adfyrtiofem\\u00adtusen sexhundra\\u00adsjuttio\\u00e5tta" },
-            { "123,456.789", "etthundra\\u00adtjugotre\\u00adtusen fyrahundra\\u00adfemtiosex komma sju \\u00e5tta nio" },
-            { "-12,345.678", "minus tolv\\u00adtusen trehundra\\u00adfyrtiofem komma sex sju \\u00e5tta" },
+            { "12,345,678", "tolv miljoner tre\\u00adhundra\\u00adfyrtio\\u00adfem\\u00adtusen sex\\u00adhundra\\u00adsjuttio\\u00ad\\u00e5tta" },
+            { "123,456.789", "ett\\u00adhundra\\u00adtjugo\\u00adtre\\u00adtusen fyra\\u00adhundra\\u00adfemtio\\u00adsex komma sju \\u00e5tta nio" },
+            { "-12,345.678", "minus tolv\\u00adtusen tre\\u00adhundra\\u00adfyrtio\\u00adfem komma sex sju \\u00e5tta" },
             { NULL, NULL }
         };
         doTest(formatter, testDataDefault, TRUE);
 
             { NULL, NULL }
         };
         doTest(formatter, testDataDefault, TRUE);
 
-        static const char* testDataNeutrum[][2] = {
-            { "101", "etthundra\\u00adett" },
-            { "1,001", "ettusen ett" },
-            { "1,101", "ettusen etthundra\\u00adett" },
-            { "10,001", "tio\\u00adtusen ett" },
-            { "21,001", "tjugoen\\u00adtusen ett" },
-            { NULL, NULL }
-        };
-
-        formatter->setDefaultRuleSet("%neutrum", status);
-        if (U_SUCCESS(status)) {
-            logln("testing neutrum rules");
-            doTest(formatter, testDataNeutrum, TRUE);
-        }
-        else {
-            errln("Can't test neutrum rules");
-        }
+          static const char* testDataNeutrum[][2] = {
+              { "101", "ett\\u00adhundra\\u00adett" },
+              { "1,001", "et\\u00adtusen ett" },
+              { "1,101", "et\\u00adtusen ett\\u00adhundra\\u00adett" },
+              { "10,001", "tio\\u00adtusen ett" },
+              { "21,001", "tjugo\\u00adet\\u00adtusen ett" },
+              { NULL, NULL }
+          };
+  
+          formatter->setDefaultRuleSet("%spellout-cardinal-neuter", status);
+          if (U_SUCCESS(status)) {
+          logln("        testing spellout-cardinal-neuter rules");
+          doTest(formatter, testDataNeutrum, TRUE);
+          }
+          else {
+          errln("Can't test spellout-cardinal-neuter rules");
+          }
 
         static const char* testDataYear[][2] = {
 
         static const char* testDataYear[][2] = {
-            { "101", "etthundra\\u00adett" },
-            { "900", "niohundra" },
-            { "1,001", "tiohundra\\u00adett" },
-            { "1,100", "elvahundra" },
-            { "1,101", "elvahundra\\u00adett" },
-            { "1,234", "tolvhundra\\u00adtrettiofyra" },
-            { "2,001", "tjugohundra\\u00adett" },
+            { "101", "ett\\u00adhundra\\u00adett" },
+            { "900", "nio\\u00adhundra" },
+            { "1,001", "et\\u00adtusen ett" },
+            { "1,100", "elva\\u00adhundra" },
+            { "1,101", "elva\\u00adhundra\\u00adett" },
+            { "1,234", "tolv\\u00adhundra\\u00adtrettio\\u00adfyra" },
+            { "2,001", "tjugo\\u00adhundra\\u00adett" },
             { "10,001", "tio\\u00adtusen ett" },
             { NULL, NULL }
         };
 
             { "10,001", "tio\\u00adtusen ett" },
             { NULL, NULL }
         };
 
-        formatter->setDefaultRuleSet("%year", status);
+        status = U_ZERO_ERROR;
+        formatter->setDefaultRuleSet("%spellout-numbering-year", status);
         if (U_SUCCESS(status)) {
             logln("testing year rules");
             doTest(formatter, testDataYear, TRUE);
         if (U_SUCCESS(status)) {
             logln("testing year rules");
             doTest(formatter, testDataYear, TRUE);
@@ -1422,23 +1718,566 @@ IntlTestRBNF::TestSwedishSpellout()
     delete formatter;
 }
 
     delete formatter;
 }
 
+void
+IntlTestRBNF::TestSmallValues()
+{
+    UErrorCode status = U_ZERO_ERROR;
+    RuleBasedNumberFormat* formatter
+        = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("en_US"), status);
+
+    if (U_FAILURE(status)) {
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));
+    } else {
+        static const char* const testDataDefault[][2] = {
+        { "0.001", "zero point zero zero one" },
+        { "0.0001", "zero point zero zero zero one" },
+        { "0.00001", "zero point zero zero zero zero one" },
+        { "0.000001", "zero point zero zero zero zero zero one" },
+        { "0.0000001", "zero point zero zero zero zero zero zero one" },
+        { "0.00000001", "zero point zero zero zero zero zero zero zero one" },
+        { "0.000000001", "zero point zero zero zero zero zero zero zero zero one" },
+        { "0.0000000001", "zero point zero zero zero zero zero zero zero zero zero one" },
+        { "0.00000000001", "zero point zero zero zero zero zero zero zero zero zero zero one" },
+        { "0.000000000001", "zero point zero zero zero zero zero zero zero zero zero zero zero one" },
+        { "0.0000000000001", "zero point zero zero zero zero zero zero zero zero zero zero zero zero one" },
+        { "0.00000000000001", "zero point zero zero zero zero zero zero zero zero zero zero zero zero zero one" },
+        { "0.000000000000001", "zero point zero zero zero zero zero zero zero zero zero zero zero zero zero zero one" },
+        { "10,000,000.001", "ten million point zero zero one" },
+        { "10,000,000.0001", "ten million point zero zero zero one" },
+        { "10,000,000.00001", "ten million point zero zero zero zero one" },
+        { "10,000,000.000001", "ten million point zero zero zero zero zero one" },
+        { "10,000,000.0000001", "ten million point zero zero zero zero zero zero one" },
+//        { "10,000,000.00000001", "ten million point zero zero zero zero zero zero zero one" },
+//        { "10,000,000.000000002", "ten million point zero zero zero zero zero zero zero zero two" },
+        { "10,000,000", "ten million" },
+//        { "1,234,567,890.0987654", "one billion, two hundred and thirty-four million, five hundred and sixty-seven thousand, eight hundred and ninety point zero nine eight seven six five four" },
+//        { "123,456,789.9876543", "one hundred and twenty-three million, four hundred and fifty-six thousand, seven hundred and eighty-nine point nine eight seven six five four three" },
+//        { "12,345,678.87654321", "twelve million, three hundred and forty-five thousand, six hundred and seventy-eight point eight seven six five four three two one" },
+        { "1,234,567.7654321", "one million two hundred thirty-four thousand five hundred sixty-seven point seven six five four three two one" },
+        { "123,456.654321", "one hundred twenty-three thousand four hundred fifty-six point six five four three two one" },
+        { "12,345.54321", "twelve thousand three hundred forty-five point five four three two one" },
+        { "1,234.4321", "one thousand two hundred thirty-four point four three two one" },
+        { "123.321", "one hundred twenty-three point three two one" },
+        { "0.0000000011754944", "zero point zero zero zero zero zero zero zero zero one one seven five four nine four four" },
+        { "0.000001175494351", "zero point zero zero zero zero zero one one seven five four nine four three five one" },
+        { NULL, NULL }
+        };
+
+        doTest(formatter, testDataDefault, TRUE);
+
+        delete formatter;
+    }
+}
+
+void 
+IntlTestRBNF::TestLocalizations(void)
+{
+    int i;
+    UnicodeString rules("%main:0:no;1:some;100:a lot;1000:tons;\n"
+        "%other:0:nada;1:yah, some;100:plenty;1000:more'n you'll ever need");
+
+    UErrorCode status = U_ZERO_ERROR;
+    UParseError perror;
+    RuleBasedNumberFormat formatter(rules, perror, status);
+    if (U_FAILURE(status)) {
+        errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status));           
+    } else {
+        {
+            static const char* const testData[][2] = {
+                { "0", "nada" },
+                { "5", "yah, some" },
+                { "423", "plenty" },
+                { "12345", "more'n you'll ever need" },
+                { NULL, NULL }
+            };
+            doTest(&formatter, testData, FALSE);
+        }
+
+        {
+            UnicodeString loc("<<%main, %other>,<en, Main, Other>,<fr, leMain, leOther>,<de, 'das Main', 'etwas anderes'>>");
+            static const char* const testData[][2] = {
+                { "0", "no" },
+                { "5", "some" },
+                { "423", "a lot" },
+                { "12345", "tons" },
+                { NULL, NULL }
+            };
+            RuleBasedNumberFormat formatter0(rules, loc, perror, status);
+            if (U_FAILURE(status)) {
+                errln("failed to build second formatter");
+            } else {
+                doTest(&formatter0, testData, FALSE);
+
+                {
+                // exercise localization info
+                    Locale locale0("en__VALLEY@turkey=gobblegobble");
+                    Locale locale1("de_DE_FOO");
+                    Locale locale2("ja_JP");
+                    UnicodeString name = formatter0.getRuleSetName(0);
+                    if ( formatter0.getRuleSetDisplayName(0, locale0) == "Main"
+                      && formatter0.getRuleSetDisplayName(0, locale1) == "das Main"
+                      && formatter0.getRuleSetDisplayName(0, locale2) == "%main"
+                      && formatter0.getRuleSetDisplayName(name, locale0) == "Main"
+                      && formatter0.getRuleSetDisplayName(name, locale1) == "das Main"
+                      && formatter0.getRuleSetDisplayName(name, locale2) == "%main"){
+                          logln("getRuleSetDisplayName tested");
+                    }else {
+                        errln("failed to getRuleSetDisplayName");
+                    }
+                }
+
+                for (i = 0; i < formatter0.getNumberOfRuleSetDisplayNameLocales(); ++i) {
+                    Locale locale = formatter0.getRuleSetDisplayNameLocale(i, status);
+                    if (U_SUCCESS(status)) {
+                        for (int j = 0; j < formatter0.getNumberOfRuleSetNames(); ++j) {
+                            UnicodeString name = formatter0.getRuleSetName(j);
+                            UnicodeString lname = formatter0.getRuleSetDisplayName(j, locale);
+                            UnicodeString msg = locale.getName();
+                            msg.append(": ");
+                            msg.append(name);
+                            msg.append(" = ");
+                            msg.append(lname);
+                            logln(msg);
+                        }
+                    }
+                }
+            }
+        }
+
+        {
+            static const char* goodLocs[] = {
+                "", // zero-length ok, same as providing no localization data
+                "<<>>", // no public rule sets ok
+                "<<%main>>", // no localizations ok
+                "<<%main,>,<en, Main,>>", // comma before close angle ok
+                "<<%main>,<en, ',<>\" '>>", // quotes everything until next quote
+                "<<%main>,<'en', \"it's ok\">>", // double quotes work too
+                "  \n <\n  <\n  %main\n  >\n  , \t <\t   en\t  ,  \tfoo \t\t > \n\n >  \n ", // Pattern_White_Space ok
+           }; 
+            int32_t goodLocsLen = UPRV_LENGTHOF(goodLocs);
+
+            static const char* badLocs[] = {
+                " ", // non-zero length
+                "<>", // empty array
+                "<", // unclosed outer array
+                "<<", // unclosed inner array
+                "<<,>>", // unexpected comma
+                "<<''>>", // empty string
+                "  x<<%main>>", // first non space char not open angle bracket
+                "<%main>", // missing inner array
+                "<<%main %other>>", // elements missing separating commma (spaces must be quoted)
+                "<<%main><en, Main>>", // arrays missing separating comma
+                "<<%main>,<en, main, foo>>", // too many elements in locale data
+                "<<%main>,<en>>", // too few elements in locale data
+                "<<<%main>>>", // unexpected open angle
+                "<<%main<>>>", // unexpected open angle
+                "<<%main, %other>,<en,,>>", // implicit empty strings
+                "<<%main>,<en,''>>", // empty string
+                "<<%main>, < en, '>>", // unterminated quote
+                "<<%main>, < en, \"<>>", // unterminated quote
+                "<<%main\">>", // quote in string
+                "<<%main'>>", // quote in string
+                "<<%main<>>", // open angle in string
+                "<<%main>> x", // extra non-space text at end
+
+            };
+            int32_t badLocsLen = UPRV_LENGTHOF(badLocs);
+
+            for (i = 0; i < goodLocsLen; ++i) {
+                logln("[%d] '%s'", i, goodLocs[i]);
+                UErrorCode status = U_ZERO_ERROR;
+                UnicodeString loc(goodLocs[i]);
+                RuleBasedNumberFormat fmt(rules, loc, perror, status);
+                if (U_FAILURE(status)) {
+                    errln("Failed parse of good localization string: '%s'", goodLocs[i]);
+                }
+            }
+
+            for (i = 0; i < badLocsLen; ++i) {
+                logln("[%d] '%s'", i, badLocs[i]);
+                UErrorCode status = U_ZERO_ERROR;
+                UnicodeString loc(badLocs[i]);
+                RuleBasedNumberFormat fmt(rules, loc, perror, status);
+                if (U_SUCCESS(status)) {
+                    errln("Successful parse of bad localization string: '%s'", badLocs[i]);
+                }
+            }
+        }
+    }
+}
+
+void
+IntlTestRBNF::TestAllLocales()
+{
+    const char* names[] = {
+        " (spellout) ",
+        " (ordinal)  "
+        // " (duration) " // This is English only, and it's not really supported in CLDR anymore.
+    };
+    double numbers[] = {45.678, 1, 2, 10, 11, 100, 110, 200, 1000, 1111, -1111};
+
+    int32_t count = 0;
+    const Locale* locales = Locale::getAvailableLocales(count);
+    for (int i = 0; i < count; ++i) {
+        const Locale* loc = &locales[i];
+
+        for (int j = 0; j < 2; ++j) {
+            UErrorCode status = U_ZERO_ERROR;
+            RuleBasedNumberFormat* f = new RuleBasedNumberFormat((URBNFRuleSetTag)j, *loc, status);
+
+            if (status == U_USING_DEFAULT_WARNING || status == U_USING_FALLBACK_WARNING) {
+                // Skip it.
+                delete f;
+                break;
+            }
+            if (U_FAILURE(status)) {
+                errln(UnicodeString(loc->getName()) + names[j]
+                    + "ERROR could not instantiate -> " + u_errorName(status));
+                continue;
+            }
+#if !UCONFIG_NO_COLLATION
+            for (unsigned int numidx = 0; numidx < UPRV_LENGTHOF(numbers); numidx++) {
+                double n = numbers[numidx];
+                UnicodeString str;
+                f->format(n, str);
+
+                if (verbose) {
+                    logln(UnicodeString(loc->getName()) + names[j]
+                        + "success: " + n + " -> " + str);
+                }
+
+                // We do not validate the result in this test case,
+                // because there are cases which do not round trip by design.
+                Formattable num;
+
+                // regular parse
+                status = U_ZERO_ERROR;
+                f->setLenient(FALSE);
+                f->parse(str, num, status);
+                if (U_FAILURE(status)) {
+                    errln(UnicodeString(loc->getName()) + names[j]
+                        + "ERROR could not parse '" + str + "' -> " + u_errorName(status));
+                }
+                // We only check the spellout. The behavior is undefined for numbers < 1 and fractional numbers.
+                if (j == 0) {
+                    if (num.getType() == Formattable::kLong && num.getLong() != n) {
+                        errln(UnicodeString(loc->getName()) + names[j]
+                            + UnicodeString("ERROR could not roundtrip ") + n
+                            + UnicodeString(" -> ") + str + UnicodeString(" -> ") + num.getLong());
+                    }
+                    else if (num.getType() == Formattable::kDouble && (int64_t)(num.getDouble() * 1000) != (int64_t)(n*1000)) {
+                        // The epsilon difference is too high.
+                        errln(UnicodeString(loc->getName()) + names[j]
+                            + UnicodeString("ERROR could not roundtrip ") + n
+                            + UnicodeString(" -> ") + str + UnicodeString(" -> ") + num.getDouble());
+                    }
+                }
+                if (!quick && !logKnownIssue("9503") ) {
+                    // lenient parse
+                    status = U_ZERO_ERROR;
+                    f->setLenient(TRUE);
+                    f->parse(str, num, status);
+                    if (U_FAILURE(status)) {
+                        errln(UnicodeString(loc->getName()) + names[j]
+                            + "ERROR could not parse(lenient) '" + str + "' -> " + u_errorName(status));
+                    }
+                    // We only check the spellout. The behavior is undefined for numbers < 1 and fractional numbers.
+                    if (j == 0) {
+                        if (num.getType() == Formattable::kLong && num.getLong() != n) {
+                            errln(UnicodeString(loc->getName()) + names[j]
+                                + UnicodeString("ERROR could not roundtrip ") + n
+                                + UnicodeString(" -> ") + str + UnicodeString(" -> ") + num.getLong());
+                        }
+                        else if (num.getType() == Formattable::kDouble && (int64_t)(num.getDouble() * 1000) != (int64_t)(n*1000)) {
+                            // The epsilon difference is too high.
+                            errln(UnicodeString(loc->getName()) + names[j]
+                                + UnicodeString("ERROR could not roundtrip ") + n
+                                + UnicodeString(" -> ") + str + UnicodeString(" -> ") + num.getDouble());
+                        }
+                    }
+                }
+            }
+#endif
+            delete f;
+        }
+    }
+}
+
+void 
+IntlTestRBNF::TestMultiplierSubstitution(void) {
+    UnicodeString rules("=#,##0=;1,000,000: <##0.###< million;");
+    UErrorCode status = U_ZERO_ERROR;
+    UParseError parse_error;
+    RuleBasedNumberFormat *rbnf = 
+        new RuleBasedNumberFormat(rules, Locale::getUS(), parse_error, status);
+    if (U_SUCCESS(status)) {
+        UnicodeString res;
+        FieldPosition pos;
+        double n = 1234000.0;
+        rbnf->format(n, res, pos);
+        delete rbnf;
+
+        UnicodeString expected(UNICODE_STRING_SIMPLE("1.234 million"));
+        if (expected != res) {
+            UnicodeString msg = "Expected: ";
+            msg.append(expected);
+            msg.append(" but got ");
+            msg.append(res);
+            errln(msg);
+        }
+    }
+}
+
+void
+IntlTestRBNF::TestSetDecimalFormatSymbols() {
+    UErrorCode status = U_ZERO_ERROR;
+
+    RuleBasedNumberFormat rbnf(URBNF_ORDINAL, Locale::getEnglish(), status);
+    if (U_FAILURE(status)) {
+        dataerrln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+
+    DecimalFormatSymbols dfs(Locale::getEnglish(), status);
+    if (U_FAILURE(status)) {
+        errln("Unable to create DecimalFormatSymbols - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+
+    UnicodeString expected[] = {
+            UnicodeString("1,001st"),
+            UnicodeString("1&001st")
+    };
+
+    double number = 1001;
+
+    UnicodeString result;
+
+    rbnf.format(number, result);
+    if (result != expected[0]) {
+        errln("Format Error - Got: " + result + " Expected: " + expected[0]);
+    }
+
+    result.remove();
+
+    /* Set new symbol for testing */
+    dfs.setSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol, UnicodeString("&"), TRUE);
+    rbnf.setDecimalFormatSymbols(dfs);
+
+    rbnf.format(number, result);
+    if (result != expected[1]) {
+        errln("Format Error - Got: " + result + " Expected: " + expected[1]);
+    }
+}
+
+void IntlTestRBNF::TestPluralRules() {
+    UErrorCode status = U_ZERO_ERROR;
+    UnicodeString enRules("%digits-ordinal:-x: ->>;0: =#,##0=$(ordinal,one{st}two{nd}few{rd}other{th})$;");
+    UParseError parseError;
+    RuleBasedNumberFormat enFormatter(enRules, Locale::getEnglish(), parseError, status);
+    if (U_FAILURE(status)) {
+        dataerrln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+    const char* const enTestData[][2] = {
+            { "1", "1st" },
+            { "2", "2nd" },
+            { "3", "3rd" },
+            { "4", "4th" },
+            { "11", "11th" },
+            { "12", "12th" },
+            { "13", "13th" },
+            { "14", "14th" },
+            { "21", "21st" },
+            { "22", "22nd" },
+            { "23", "23rd" },
+            { "24", "24th" },
+            { NULL, NULL }
+    };
+
+    doTest(&enFormatter, enTestData, TRUE);
+
+    // This is trying to model the feminine form, but don't worry about the details too much.
+    // We're trying to test the plural rules.
+    UnicodeString ruRules("%spellout-numbering:"
+            "-x: minus >>;"
+            "x.x: << point >>;"
+            "0: zero;"
+            "1: one;"
+            "2: two;"
+            "3: three;"
+            "4: four;"
+            "5: five;"
+            "6: six;"
+            "7: seven;"
+            "8: eight;"
+            "9: nine;"
+            "10: ten;"
+            "11: eleven;"
+            "12: twelve;"
+            "13: thirteen;"
+            "14: fourteen;"
+            "15: fifteen;"
+            "16: sixteen;"
+            "17: seventeen;"
+            "18: eighteen;"
+            "19: nineteen;"
+            "20: twenty[->>];"
+            "30: thirty[->>];"
+            "40: forty[->>];"
+            "50: fifty[->>];"
+            "60: sixty[->>];"
+            "70: seventy[->>];"
+            "80: eighty[->>];"
+            "90: ninety[->>];"
+            "100: hundred[ >>];"
+            "200: << hundred[ >>];"
+            "300: << hundreds[ >>];"
+            "500: << hundredss[ >>];"
+            "1000: << $(cardinal,one{thousand}few{thousands}other{thousandss})$[ >>];"
+            "1000000: << $(cardinal,one{million}few{millions}other{millionss})$[ >>];");
+    RuleBasedNumberFormat ruFormatter(ruRules, Locale("ru"), parseError, status);
+    const char* const ruTestData[][2] = {
+            { "1", "one" },
+            { "100", "hundred" },
+            { "125", "hundred twenty-five" },
+            { "399", "three hundreds ninety-nine" },
+            { "1,000", "one thousand" },
+            { "1,001", "one thousand one" },
+            { "2,000", "two thousands" },
+            { "2,001", "two thousands one" },
+            { "2,002", "two thousands two" },
+            { "3,333", "three thousands three hundreds thirty-three" },
+            { "5,000", "five thousandss" },
+            { "11,000", "eleven thousandss" },
+            { "21,000", "twenty-one thousand" },
+            { "22,000", "twenty-two thousands" },
+            { "25,001", "twenty-five thousandss one" },
+            { NULL, NULL }
+    };
+
+    if (U_FAILURE(status)) {
+        errln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+    doTest(&ruFormatter, ruTestData, TRUE);
+
+    // Make sure there are no divide by 0 errors.
+    UnicodeString result;
+    RuleBasedNumberFormat(ruRules, Locale("ru"), parseError, status).format(21000, result);
+    if (result.compare(UNICODE_STRING_SIMPLE("twenty-one thousand")) != 0) {
+        errln("Got " + result + " for 21000");
+    }
+
+}
+
+void IntlTestRBNF::TestInfinityNaN() {
+    UErrorCode status = U_ZERO_ERROR;
+    UParseError parseError;
+    UnicodeString enRules("%default:"
+            "-x: minus >>;"
+            "Inf: infinite;"
+            "NaN: not a number;"
+            "0: =#,##0=;");
+    RuleBasedNumberFormat enFormatter(enRules, Locale::getEnglish(), parseError, status);
+    const char * const enTestData[][2] = {
+            {"1", "1"},
+            {"\\u221E", "infinite"},
+            {"-\\u221E", "minus infinite"},
+            {"NaN", "not a number"},
+            { NULL, NULL }
+    };
+    if (U_FAILURE(status)) {
+        dataerrln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+
+    doTest(&enFormatter, enTestData, true);
+
+    // Test the default behavior when the rules are undefined.
+    UnicodeString enRules2("%default:"
+            "-x: ->>;"
+            "0: =#,##0=;");
+    RuleBasedNumberFormat enFormatter2(enRules2, Locale::getEnglish(), parseError, status);
+    if (U_FAILURE(status)) {
+        errln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+    const char * const enDefaultTestData[][2] = {
+            {"1", "1"},
+            {"\\u221E", "\\u221E"},
+            {"-\\u221E", "-\\u221E"},
+            {"NaN", "NaN"},
+            { NULL, NULL }
+    };
+
+    doTest(&enFormatter2, enDefaultTestData, true);
+}
+
+void IntlTestRBNF::TestVariableDecimalPoint() {
+    UErrorCode status = U_ZERO_ERROR;
+    UParseError parseError;
+    UnicodeString enRules("%spellout-numbering:"
+            "-x: minus >>;"
+            "x.x: << point >>;"
+            "x,x: << comma >>;"
+            "0.x: xpoint >>;"
+            "0,x: xcomma >>;"
+            "0: zero;"
+            "1: one;"
+            "2: two;"
+            "3: three;"
+            "4: four;"
+            "5: five;"
+            "6: six;"
+            "7: seven;"
+            "8: eight;"
+            "9: nine;");
+    RuleBasedNumberFormat enFormatter(enRules, Locale::getEnglish(), parseError, status);
+    const char * const enTestPointData[][2] = {
+            {"1.1", "one point one"},
+            {"1.23", "one point two three"},
+            {"0.4", "xpoint four"},
+            { NULL, NULL }
+    };
+    if (U_FAILURE(status)) {
+        dataerrln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
+        return;
+    }
+    doTest(&enFormatter, enTestPointData, true);
+
+    DecimalFormatSymbols decimalFormatSymbols(Locale::getEnglish(), status);
+    decimalFormatSymbols.setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, UNICODE_STRING_SIMPLE(","));
+    enFormatter.setDecimalFormatSymbols(decimalFormatSymbols);
+    const char * const enTestCommaData[][2] = {
+            {"1.1", "one comma one"},
+            {"1.23", "one comma two three"},
+            {"0.4", "xcomma four"},
+            { NULL, NULL }
+    };
+    doTest(&enFormatter, enTestCommaData, true);
+}
 
 void 
 
 void 
-IntlTestRBNF::doTest(RuleBasedNumberFormat* formatter, const char* testData[][2], UBool testParsing) 
+IntlTestRBNF::doTest(RuleBasedNumberFormat* formatter, const char* const testData[][2], UBool testParsing) 
 {
   // man, error reporting would be easier with printf-style syntax for unicode string and formattable
 
     UErrorCode status = U_ZERO_ERROR;
 {
   // man, error reporting would be easier with printf-style syntax for unicode string and formattable
 
     UErrorCode status = U_ZERO_ERROR;
-    NumberFormat* decFmt = NumberFormat::createInstance(Locale::getUS(), status);
+    DecimalFormatSymbols dfs("en", status);
+    // NumberFormat* decFmt = NumberFormat::createInstance(Locale::getUS(), status);
+    DecimalFormat decFmt("#,###.################", dfs, status);
     if (U_FAILURE(status)) {
     if (U_FAILURE(status)) {
-        errln("FAIL: could not create NumberFormat");
+        errcheckln(status, "FAIL: could not create NumberFormat - %s", u_errorName(status));
     } else {
         for (int i = 0; testData[i][0]; ++i) {
             const char* numString = testData[i][0];
             const char* expectedWords = testData[i][1];
 
     } else {
         for (int i = 0; testData[i][0]; ++i) {
             const char* numString = testData[i][0];
             const char* expectedWords = testData[i][1];
 
+            log("[%i] %s = ", i, numString);
             Formattable expectedNumber;
             Formattable expectedNumber;
-            decFmt->parse(numString, expectedNumber, status);
+            UnicodeString escapedNumString = UnicodeString(numString, -1, US_INV).unescape();
+            decFmt.parse(escapedNumString, expectedNumber, status);
             if (U_FAILURE(status)) {
                 errln("FAIL: decFmt could not parse %s", numString);
                 break;
             if (U_FAILURE(status)) {
                 errln("FAIL: decFmt could not parse %s", numString);
                 break;
@@ -1448,49 +2287,51 @@ IntlTestRBNF::doTest(RuleBasedNumberFormat* formatter, const char* testData[][2]
                 formatter->format(expectedNumber, actualString/* , pos*/, status);
                 if (U_FAILURE(status)) {
                     UnicodeString msg = "Fail: formatter could not format ";
                 formatter->format(expectedNumber, actualString/* , pos*/, status);
                 if (U_FAILURE(status)) {
                     UnicodeString msg = "Fail: formatter could not format ";
-                    decFmt->format(expectedNumber, msg, status);
+                    decFmt.format(expectedNumber, msg, status);
                     errln(msg);
                     break;
                 } else {
                     errln(msg);
                     break;
                 } else {
-                    UnicodeString expectedString = UnicodeString(expectedWords).unescape();
+                    UnicodeString expectedString = UnicodeString(expectedWords, -1, US_INV).unescape();
                     if (actualString != expectedString) {
                         UnicodeString msg = "FAIL: check failed for ";
                     if (actualString != expectedString) {
                         UnicodeString msg = "FAIL: check failed for ";
-                        decFmt->format(expectedNumber, msg, status);
+                        decFmt.format(expectedNumber, msg, status);
                         msg.append(", expected ");
                         msg.append(expectedString);
                         msg.append(" but got ");
                         msg.append(actualString);
                         errln(msg);
                         break;
                         msg.append(", expected ");
                         msg.append(expectedString);
                         msg.append(" but got ");
                         msg.append(actualString);
                         errln(msg);
                         break;
-                    } else if (testParsing) {
-                        Formattable parsedNumber;
-                        formatter->parse(actualString, parsedNumber, status);
-                        if (U_FAILURE(status)) {
-                            UnicodeString msg = "FAIL: formatter could not parse ";
-                            msg.append(actualString);
-                            msg.append(" status code: " );
-                            char buffer[32];
-                            sprintf(buffer, "0x%x", status);
-                            msg.append(buffer);
-                            errln(msg);
-                            break;
-                        } else {
-                            if (parsedNumber != expectedNumber) {
-                                UnicodeString msg = "FAIL: parse failed for ";
+                    } else {
+                        logln(actualString);
+                        if (testParsing) {
+                            Formattable parsedNumber;
+                            formatter->parse(actualString, parsedNumber, status);
+                            if (U_FAILURE(status)) {
+                                UnicodeString msg = "FAIL: formatter could not parse ";
                                 msg.append(actualString);
                                 msg.append(actualString);
-                                msg.append(", expected ");
-                                decFmt->format(expectedNumber, msg, status);
-                                msg.append(", but got ");
-                                decFmt->format(parsedNumber, msg, status);
+                                msg.append(" status code: " );
+                                msg.append(u_errorName(status));
                                 errln(msg);
                                 break;
                                 errln(msg);
                                 break;
+                            } else {
+                                if (parsedNumber != expectedNumber
+                                    && (!uprv_isNaN(parsedNumber.getDouble()) || !uprv_isNaN(expectedNumber.getDouble())))
+                                {
+                                    UnicodeString msg = "FAIL: parse failed for ";
+                                    msg.append(actualString);
+                                    msg.append(", expected ");
+                                    decFmt.format(expectedNumber, msg, status);
+                                    msg.append(", but got ");
+                                    decFmt.format(parsedNumber, msg, status);
+                                    errln(msg);
+                                    break;
+                                }
                             }
                         }
                     }
                 }
             }
         }
                             }
                         }
                     }
                 }
             }
         }
-        delete decFmt;
     }
 }
 
     }
 }
 
@@ -1500,7 +2341,7 @@ IntlTestRBNF::doLenientParseTest(RuleBasedNumberFormat* formatter, const char* t
     UErrorCode status = U_ZERO_ERROR;
     NumberFormat* decFmt = NumberFormat::createInstance(Locale::getUS(), status);
     if (U_FAILURE(status)) {
     UErrorCode status = U_ZERO_ERROR;
     NumberFormat* decFmt = NumberFormat::createInstance(Locale::getUS(), status);
     if (U_FAILURE(status)) {
-        errln("FAIL: could not create NumberFormat");
+        errcheckln(status, "FAIL: could not create NumberFormat - %s", u_errorName(status));
     } else {
         for (int i = 0; testData[i][0]; ++i) {
             const char* spelledNumber = testData[i][0]; // spelled-out number
     } else {
         for (int i = 0; testData[i][0]; ++i) {
             const char* spelledNumber = testData[i][0]; // spelled-out number