Ejemplo n.º 1
0
        public void Test_parseLjava_lang_StringLjava_text_ParsePosition()
        {
            // Test for method java.lang.Object []
            // java.text.IBM.ICU.Text.MessageFormat.parse(java.lang.String,
            // java.text.ParsePosition)
            IBM.ICU.Text.MessageFormat format = new IBM.ICU.Text.MessageFormat("date is {0,date,MMM d, yyyy}");
            ParsePosition pos = new ParsePosition(2);

            Object[] result = (Object[])format
                              .Parse("xxdate is Feb 28, 1999", pos);
            NUnit.Framework.Assert.IsTrue(result.Length >= 1, "No result: " + result.Length);
            NUnit.Framework.Assert.IsTrue(((DateTime)result[0]).Equals(new IBM.ICU.Util.GregorianCalendar(1999,
                                                                                                          IBM.ICU.Util.Calendar.FEBRUARY, 28).GetTime()), "Wrong answer");

            IBM.ICU.Text.MessageFormat mf = new IBM.ICU.Text.MessageFormat("vm={0},{1},{2}");
            result = mf.Parse("vm=win,foo,bar", new ParsePosition(0));
            NUnit.Framework.Assert.IsTrue(result[0].Equals("win") && result[1].Equals("foo") &&
                                          result[2].Equals("bar"), "Invalid parse");

            mf = new IBM.ICU.Text.MessageFormat("{0}; {0}; {0}");
            String parse = "a; b; c";

            result = mf.Parse(parse, new ParsePosition(0));
            NUnit.Framework.Assert.AreEqual("c", result[0], "Wrong variable result");
        }
Ejemplo n.º 2
0
 public void Test_parse()
 {
     // Regression for HARMONY-63
     IBM.ICU.Text.MessageFormat mf = new IBM.ICU.Text.MessageFormat("{0,number,#,####}", ILOG.J2CsMapping.Util.Locale.US);
     Object[] res = mf.Parse("1,00,00");
     NUnit.Framework.Assert.AreEqual(1, res.Length, "Assert 0: incorrect size of parsed data ");
     NUnit.Framework.Assert.AreEqual((long)(10000), (Int64)res[0], "Assert 1: parsed value incorrectly");
 }
Ejemplo n.º 3
0
 public void Test_setLocaleLjava_util_Locale()
 {
     // Test for method void
     // java.text.IBM.ICU.Text.MessageFormat.setLocale(java.util.Locale)
     IBM.ICU.Text.MessageFormat format = new IBM.ICU.Text.MessageFormat("date {0,date}");
     format.SetLocale(ILOG.J2CsMapping.Util.Locale.CHINA);
     NUnit.Framework.Assert.AreEqual(ILOG.J2CsMapping.Util.Locale.CHINA, format.GetLocale(), "Wrong locale1");
     format.ApplyPattern("{1,date}");
     NUnit.Framework.Assert.AreEqual(IBM.ICU.Text.DateFormat.GetDateInstance(IBM.ICU.Text.DateFormat.DEFAULT, ILOG.J2CsMapping.Util.Locale.CHINA), format.GetFormats()[0], "Wrong locale3");
 }
Ejemplo n.º 4
0
        public void Test_toPattern()
        {
            // Test for method java.lang.String java.text.IBM.ICU.Text.MessageFormat.toPattern()
            String pattern = "[{0}]";

            IBM.ICU.Text.MessageFormat mf = new IBM.ICU.Text.MessageFormat(pattern);
            NUnit.Framework.Assert.IsTrue(mf.ToPattern().Equals(pattern), "Wrong pattern");

            // Regression for HARMONY-59
            new IBM.ICU.Text.MessageFormat("CHOICE {1,choice}").ToPattern();
        }
Ejemplo n.º 5
0
        public void Test_format_Object()
        {
            // Regression for HARMONY-1875
            ILOG.J2CsMapping.Util.Locale.SetDefault(ILOG.J2CsMapping.Util.Locale.CANADA);
            IBM.ICU.Util.TimeZone.SetDefault(IBM.ICU.Util.TimeZone.GetTimeZone("UTC"));
            String pat    = "text here {0, date, yyyyyyyyy } and here";
            String etalon = "text here  000002007  and here";

            IBM.ICU.Text.MessageFormat obj = new IBM.ICU.Text.MessageFormat(pat);
            NUnit.Framework.Assert.AreEqual(etalon, obj.FormatObject(new Object[] { new DateTime((1198141737640L) * 10000) }));

            NUnit.Framework.Assert.AreEqual("{0}", IBM.ICU.Text.MessageFormat.Format("{0}", (Object[])null));
            NUnit.Framework.Assert.AreEqual("nullABC", IBM.ICU.Text.MessageFormat.Format("{0}{1}", new String[] { null, "ABC" }));
        }
Ejemplo n.º 6
0
 public void Test_equalsLjava_lang_Object()
 {
     // Test for method boolean
     // java.text.IBM.ICU.Text.MessageFormat.equals(java.lang.Object)
     IBM.ICU.Text.MessageFormat format1_0 = new IBM.ICU.Text.MessageFormat("{0}");
     IBM.ICU.Text.MessageFormat format2_1 = new IBM.ICU.Text.MessageFormat("{1}");
     NUnit.Framework.Assert.IsTrue(!format1_0.Equals(format2_1), "Should not be equal");
     format2_1.ApplyPattern("{0}");
     NUnit.Framework.Assert.IsTrue(format1_0.Equals(format2_1), "Should be equal");
     IBM.ICU.Text.SimpleDateFormat date = (IBM.ICU.Text.SimpleDateFormat)IBM.ICU.Text.DateFormat.GetTimeInstance();
     format1_0.SetFormat(0, IBM.ICU.Text.DateFormat.GetTimeInstance());
     format2_1.SetFormat(0, new IBM.ICU.Text.SimpleDateFormat(date.ToPattern()));
     NUnit.Framework.Assert.IsTrue(format1_0.Equals(format2_1), "Should be equal2");
 }
Ejemplo n.º 7
0
 public void Test_clone()
 {
     // Test for method java.lang.Object java.text.IBM.ICU.Text.MessageFormat.clone()
     IBM.ICU.Text.MessageFormat format = new IBM.ICU.Text.MessageFormat("'{'choice'}'{0}");
     IBM.ICU.Text.MessageFormat clone  = (IBM.ICU.Text.MessageFormat)format.Clone();
     NUnit.Framework.Assert.IsTrue(format.Equals(clone), "Clone not equal");
     NUnit.Framework.Assert.AreEqual("{choice}{0}", format.FormatObject(new Object[] { }), "Wrong answer");
     clone.SetFormat(0, IBM.ICU.Text.DateFormat.GetInstance());
     NUnit.Framework.Assert.IsTrue(!format.Equals(clone), "Clone shares format data");
     format = (IBM.ICU.Text.MessageFormat)clone.Clone();
     Format[] formats = clone.GetFormats();
     ((IBM.ICU.Text.SimpleDateFormat)formats[0]).ApplyPattern("adk123");
     NUnit.Framework.Assert.IsTrue(!format.Equals(clone), "Clone shares format data");
 }
Ejemplo n.º 8
0
        public void Test_ConstructorLjava_lang_StringLjava_util_Locale()
        {
            // Test for method java.text.MessageFormat(java.lang.String,
            // java.util.Locale)
            ILOG.J2CsMapping.Util.Locale mk     = new ILOG.J2CsMapping.Util.Locale("mk", "MK");
            IBM.ICU.Text.MessageFormat   format = new IBM.ICU.Text.MessageFormat(
                "Date: {0,date} Currency: {1, number, currency} Integer: {2, number, integer}",
                mk);

            NUnit.Framework.Assert.IsTrue(format.GetLocale().Equals(mk), "Wrong locale1");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetDateInstance(IBM.ICU.Text.DateFormat.DEFAULT, mk)), "Wrong locale2");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[1].Equals(IBM.ICU.Text.NumberFormat
                                                                        .GetCurrencyInstance(mk)), "Wrong locale3");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[2].Equals(IBM.ICU.Text.NumberFormat
                                                                        .GetIntegerInstance(mk)), "Wrong locale4");
        }
Ejemplo n.º 9
0
        protected void SetUp()
        {
            defaultLocale = ILOG.J2CsMapping.Util.Locale.GetDefault();
            ILOG.J2CsMapping.Util.Locale.SetDefault(Locale.US);

            // test with repeating formats and max argument index < max offset
            String pattern = "A {3, number, currency} B {2, time} C {0, number, percent} D {4}  E {1,choice,0#off|1#on} F {0, date}";

            format1 = new IBM.ICU.Text.MessageFormat(pattern);

            // test with max argument index > max offset
            pattern = "A {3, number, currency} B {8, time} C {0, number, percent} D {6}  E {1,choice,0#off|1#on} F {0, date}";
            format2 = new IBM.ICU.Text.MessageFormat(pattern);

            // test with argument number being zero
            pattern = "A B C D E F";
            format3 = new IBM.ICU.Text.MessageFormat(pattern);
        }
Ejemplo n.º 10
0
        public void Test_format_Ljava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition()
        {
            // Test for method java.lang.StringBuffer
            // java.text.IBM.ICU.Text.MessageFormat.format(java.lang.Object [],
            // java.lang.StringBuffer, java.text.FieldPosition)
            IBM.ICU.Text.MessageFormat format = new IBM.ICU.Text.MessageFormat("{1,number,integer}");
            StringBuilder buffer = new StringBuilder();

            format.Format(new Object[] { "0", (double)(53.863d) }, buffer,
                          new FieldPosition(0));
            NUnit.Framework.Assert.AreEqual("54", buffer.ToString(), "Wrong result");
            format.ApplyPattern("{0,choice,0#zero|1#one '{1,choice,2#two {2,time}}'}");
            DateTime date     = DateTime.Now;
            String   expected = "one two "
                                + IBM.ICU.Text.DateFormat.GetTimeInstance().Format(date);
            String result = format.FormatObject(new Object[] { (double )(1.6d),
                                                               ((int)(3)), date });

            NUnit.Framework.Assert.IsTrue(expected.Equals(result), "Choice not recursive:\n" + expected + "\n" + result);
        }
Ejemplo n.º 11
0
 private void CheckSerialization(IBM.ICU.Text.MessageFormat format)
 {
     try
     {
         MemoryStream         ba   = new MemoryStream();
         IlObjectOutputStream xout = new IlObjectOutputStream(ba);
         xout.WriteObject(format);
         ((Stream)xout).Close();
         IlObjectInputStream ins0 = new IlObjectInputStream(
             new MemoryStream(ba.ToArray()));
         IBM.ICU.Text.MessageFormat read = (IBM.ICU.Text.MessageFormat)ins0.ReadObject();
         NUnit.Framework.Assert.IsTrue(format.Equals(read), "Not equal: " + format.ToPattern());
     }
     catch (IOException e)
     {
         NUnit.Framework.Assert.Fail("Format: " + format.ToPattern() + " caused IOException: " + e);
     }
     catch (TypeLoadException e_0)
     {
         NUnit.Framework.Assert.Fail("Format: " + format.ToPattern()
                                     + " caused ClassNotFoundException: " + e_0);
     }
 }
Ejemplo n.º 12
0
        public void Test_ConstructorLjava_lang_String()
        {
            // Test for method java.text.MessageFormat(java.lang.String)
            IBM.ICU.Text.MessageFormat format = new IBM.ICU.Text.MessageFormat(
                "abc {4,time} def {3,date} ghi {2,number} jkl {1,choice,0#low|1#high} mnop {0}");
            NUnit.Framework.Assert.IsTrue((Object)format.GetType() == (Object)typeof(IBM.ICU.Text.MessageFormat), "Not a IBM.ICU.Text.MessageFormat");
            ILOG.J2CsMapping.Formatting.Format[] formats = format.GetFormats();
            NUnit.Framework.Assert.IsNotNull(formats, "null formats");
            NUnit.Framework.Assert.IsTrue(formats.Length >= 5, "Wrong format count: " + formats.Length);
            NUnit.Framework.Assert.IsTrue(formats[0].Equals(IBM.ICU.Text.DateFormat.GetTimeInstance()), "Wrong time format");
            NUnit.Framework.Assert.IsTrue(formats[1].Equals(IBM.ICU.Text.DateFormat.GetDateInstance()), "Wrong date format");
            NUnit.Framework.Assert.IsTrue(formats[2].Equals(IBM.ICU.Text.NumberFormat.GetInstance()), "Wrong number format");
            NUnit.Framework.Assert.IsTrue(formats[3].Equals(new ChoiceFormat("0.0#low|1.0#high")), "Wrong choice format");
            NUnit.Framework.Assert.IsNull(formats[4], "Wrong string format");

            DateTime      date   = DateTime.Now;
            FieldPosition pos    = new FieldPosition(-1);
            StringBuilder buffer = new StringBuilder();

            format.Format(new Object[] { "123", (double )(1.6d), (double )(7.2d),
                                         date, date }, buffer, pos);
            String result = buffer.ToString();

            buffer.Length = 0;
            buffer.Append("abc ");
            buffer.Append(IBM.ICU.Text.DateFormat.GetTimeInstance().Format(date));
            buffer.Append(" def ");
            buffer.Append(IBM.ICU.Text.DateFormat.GetDateInstance().Format(date));
            buffer.Append(" ghi ");
            buffer.Append(IBM.ICU.Text.NumberFormat.GetInstance().Format((double)(7.2d)));
            buffer.Append(" jkl high mnop 123");
            NUnit.Framework.Assert.IsTrue(result.Equals(buffer.ToString()), "Wrong answer:\n" + result + "\n" + buffer);

            NUnit.Framework.Assert.AreEqual("Test message", new IBM.ICU.Text.MessageFormat(
                                                "Test message").FormatObject(new Object[0]), "Simple string");

            result = new IBM.ICU.Text.MessageFormat("Don't").FormatObject(new Object[0]);
            NUnit.Framework.Assert.IsTrue("Dont".Equals(result), "Should not throw IllegalArgumentException: " + result);

            try
            {
                new IBM.ICU.Text.MessageFormat("Invalid {1,foobar} format descriptor!");
                NUnit.Framework.Assert.Fail("Expected test_ConstructorLjava_lang_String to throw IAE.");
            }
            catch (ArgumentException ex)
            {
                // expected
            }

            try
            {
                new IBM.ICU.Text.MessageFormat(
                    "Invalid {1,date,invalid-spec} format descriptor!");
            }
            catch (ArgumentException ex_0)
            {
                // expected
            }

            //CheckSerialization(new IBM.ICU.Text.MessageFormat(""));
            //CheckSerialization(new IBM.ICU.Text.MessageFormat("noargs"));
            //CheckSerialization(new IBM.ICU.Text.MessageFormat("{0}"));
            //CheckSerialization(new IBM.ICU.Text.MessageFormat("a{0}"));
            //CheckSerialization(new IBM.ICU.Text.MessageFormat("{0}b"));
            //CheckSerialization(new IBM.ICU.Text.MessageFormat("a{0}b"));

            // Regression for HARMONY-65
            try
            {
                new IBM.ICU.Text.MessageFormat("{0,number,integer");
                NUnit.Framework.Assert.Fail("Assert 0: Failed to detect unmatched brackets.");
            }
            catch (ArgumentException e)
            {
                // expected
            }
        }
Ejemplo n.º 13
0
        public void Test_setFormatsByArgumentIndex_Ljava_text_Format()
        {
            // test for method setFormatByArgumentIndex(Format[])
            IBM.ICU.Text.MessageFormat f1 = (IBM.ICU.Text.MessageFormat)format1.Clone();

            // test with repeating formats and max argument index < max offset
            // compare getFormatsByArgumentIndex() results after calls to
            // setFormatsByArgumentIndex(Format[])
            Format[] correctFormats = new Format[] { IBM.ICU.Text.DateFormat.GetTimeInstance(),
                                                     new ChoiceFormat("0#off|1#on"), IBM.ICU.Text.DateFormat.GetTimeInstance(),
                                                     IBM.ICU.Text.NumberFormat.GetCurrencyInstance(),
                                                     new ChoiceFormat("1#few|2#ok|3#a lot") };

            f1.SetFormatsByArgumentIndex(correctFormats);
            Format[] formats = f1.GetFormatsByArgumentIndex();

            NUnit.Framework.Assert.AreEqual(correctFormats.Length, formats.Length, "Test1A:Returned wrong number of formats:");
            for (int i = 0; i < correctFormats.Length; i++)
            {
                NUnit.Framework.Assert.AreEqual(correctFormats[i], formats[i], "Test1B:wrong format for argument index " + i + ":");
            }

            // compare getFormats() results after calls to
            // setFormatByArgumentIndex()
            formats        = f1.GetFormats();
            correctFormats = new Format[] { IBM.ICU.Text.NumberFormat.GetCurrencyInstance(),
                                                IBM.ICU.Text.DateFormat.GetTimeInstance(), IBM.ICU.Text.DateFormat.GetTimeInstance(),
                                            new ChoiceFormat("1#few|2#ok|3#a lot"),
                                            new ChoiceFormat("0#off|1#on"), IBM.ICU.Text.DateFormat.GetTimeInstance(), };

            NUnit.Framework.Assert.AreEqual(correctFormats.Length, formats.Length, "Test1C:Returned wrong number of formats:");
            for (int i_0 = 0; i_0 < correctFormats.Length; i_0++)
            {
                NUnit.Framework.Assert.AreEqual(correctFormats[i_0], formats[i_0], "Test1D:wrong format for pattern index " + i_0 + ":");
            }

            // test setting argumentIndexes that are not used
            IBM.ICU.Text.MessageFormat f2 = (IBM.ICU.Text.MessageFormat)format2.Clone();
            Format[] inputFormats         = new Format[] { IBM.ICU.Text.DateFormat.GetDateInstance(),
                                                           new ChoiceFormat("0#off|1#on"),
                                                           IBM.ICU.Text.NumberFormat.GetPercentInstance(),
                                                           IBM.ICU.Text.NumberFormat.GetCurrencyInstance(),
                                                           IBM.ICU.Text.DateFormat.GetTimeInstance(), null, null, null,
                                                           IBM.ICU.Text.DateFormat.GetTimeInstance() };
            f2.SetFormatsByArgumentIndex(inputFormats);

            formats        = f2.GetFormatsByArgumentIndex();
            correctFormats = format2.GetFormatsByArgumentIndex();

            NUnit.Framework.Assert.AreEqual(correctFormats.Length, formats.Length, "Test2A:Returned wrong number of formats:");
            for (int i_1 = 0; i_1 < correctFormats.Length; i_1++)
            {
                NUnit.Framework.Assert.AreEqual(correctFormats[i_1], formats[i_1], "Test2B:wrong format for argument index " + i_1 + ":");
            }

            formats        = f2.GetFormats();
            correctFormats = new Format[] { IBM.ICU.Text.NumberFormat.GetCurrencyInstance(),
                                                IBM.ICU.Text.DateFormat.GetTimeInstance(), IBM.ICU.Text.DateFormat.GetDateInstance(),
                                                null, new ChoiceFormat("0#off|1#on"),
                                            IBM.ICU.Text.DateFormat.GetDateInstance() };

            NUnit.Framework.Assert.AreEqual(correctFormats.Length, formats.Length, "Test2C:Returned wrong number of formats:");
            for (int i_2 = 0; i_2 < correctFormats.Length; i_2++)
            {
                NUnit.Framework.Assert.AreEqual(correctFormats[i_2], formats[i_2], "Test2D:wrong format for pattern index " + i_2 + ":");
            }

            // test exceeding the argumentIndex number
            IBM.ICU.Text.MessageFormat f3 = (IBM.ICU.Text.MessageFormat)format3.Clone();
            f3.SetFormatsByArgumentIndex(inputFormats);

            formats = f3.GetFormatsByArgumentIndex();
            NUnit.Framework.Assert.AreEqual(0, formats.Length, "Test3A:Returned wrong number of formats:");

            formats = f3.GetFormats();
            NUnit.Framework.Assert.AreEqual(0, formats.Length, "Test3B:Returned wrong number of formats:");
        }
Ejemplo n.º 14
0
        public void Test_applyPatternLjava_lang_String()
        {
            // Test for method void
            // java.text.IBM.ICU.Text.MessageFormat.applyPattern(java.lang.String)
            IBM.ICU.Text.MessageFormat format = new IBM.ICU.Text.MessageFormat("test");
            format.ApplyPattern("xx {0}");
            NUnit.Framework.Assert.AreEqual("xx 46", format.FormatObject(new Object[] { ((int)(46)) }), "Invalid number");
            DateTime date     = DateTime.Now;
            String   result   = format.FormatObject(new Object[] { date });
            String   expected = "xx " + IBM.ICU.Text.DateFormat.GetInstance().Format(date);

            NUnit.Framework.Assert.IsTrue(result.Equals(expected), "Invalid date:\n" + result + "\n" + expected);
            format = new IBM.ICU.Text.MessageFormat("{0,date}{1,time}{2,number,integer}");
            format.ApplyPattern("nothing");
            NUnit.Framework.Assert.AreEqual("nothing", format.ToPattern(), "Found formats");

            format.ApplyPattern("{0}");
            NUnit.Framework.Assert.IsNull(format.GetFormats()[0], "Wrong format");
            NUnit.Framework.Assert.AreEqual("{0}", format.ToPattern(), "Wrong pattern");

            format.ApplyPattern("{0, \t\u001ftime }");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat.GetTimeInstance()), "Wrong time format");
            NUnit.Framework.Assert.AreEqual("{0,time}", format.ToPattern(), "Wrong time pattern");
            format.ApplyPattern("{0,Time, Short\n}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetTimeInstance(IBM.ICU.Text.DateFormat.SHORT)), "Wrong short time format");
            NUnit.Framework.Assert.AreEqual("{0,time,short}", format.ToPattern(), "Wrong short time pattern");
            format.ApplyPattern("{0,TIME,\nmedium  }");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetTimeInstance(IBM.ICU.Text.DateFormat.MEDIUM)), "Wrong medium time format");
            NUnit.Framework.Assert.AreEqual("{0,time}", format.ToPattern(), "Wrong medium time pattern");
            format.ApplyPattern("{0,time,LONG}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetTimeInstance(IBM.ICU.Text.DateFormat.LONG)), "Wrong long time format");
            NUnit.Framework.Assert.AreEqual("{0,time,long}", format.ToPattern(), "Wrong long time pattern");
            format.SetLocale(Locale.FRENCH);  // use French since English has the
            // same LONG and FULL time patterns
            format.ApplyPattern("{0,time, Full}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat.GetTimeInstance(
                                                                            IBM.ICU.Text.DateFormat.FULL, Locale.FRENCH)), "Wrong full time format");
            NUnit.Framework.Assert.AreEqual("{0,time,full}", format.ToPattern(), "Wrong full time pattern");
            format.SetLocale(Locale.GetDefault());

            format.ApplyPattern("{0, date}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat.GetDateInstance()), "Wrong date format");
            NUnit.Framework.Assert.AreEqual("{0,date}", format.ToPattern(), "Wrong date pattern");
            format.ApplyPattern("{0, date, short}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetDateInstance(IBM.ICU.Text.DateFormat.SHORT)), "Wrong short date format");
            NUnit.Framework.Assert.AreEqual("{0,date,short}", format.ToPattern(), "Wrong short date pattern");
            format.ApplyPattern("{0, date, medium}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetDateInstance(IBM.ICU.Text.DateFormat.MEDIUM)), "Wrong medium date format");
            NUnit.Framework.Assert.AreEqual("{0,date}", format.ToPattern(), "Wrong medium date pattern");
            format.ApplyPattern("{0, date, long}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetDateInstance(IBM.ICU.Text.DateFormat.LONG)), "Wrong long date format");
            NUnit.Framework.Assert.AreEqual("{0,date,long}", format.ToPattern(), "Wrong long date pattern");
            format.ApplyPattern("{0, date, full}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.DateFormat
                                                                        .GetDateInstance(IBM.ICU.Text.DateFormat.FULL)), "Wrong full date format");
            NUnit.Framework.Assert.AreEqual("{0,date,full}", format.ToPattern(), "Wrong full date pattern");

            format.ApplyPattern("{0, date, MMM d {hh:mm:ss}}");
            NUnit.Framework.Assert.AreEqual(" MMM d {hh:mm:ss}", ((IBM.ICU.Text.SimpleDateFormat)(format.GetFormats()[0])).ToPattern(), "Wrong time/date format");
            NUnit.Framework.Assert.AreEqual("{0,date, MMM d {hh:mm:ss}}", format.ToPattern(), "Wrong time/date pattern");

            format.ApplyPattern("{0, number}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.NumberFormat.GetNumberInstance()), "Wrong number format");
            NUnit.Framework.Assert.AreEqual("{0,number}", format.ToPattern(), "Wrong number pattern");
            format.ApplyPattern("{0, number, currency}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.NumberFormat
                                                                        .GetCurrencyInstance()), "Wrong currency number format");
            NUnit.Framework.Assert.AreEqual("{0,number,currency}", format.ToPattern(), "Wrong currency number pattern");
            format.ApplyPattern("{0, number, percent}");
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(IBM.ICU.Text.NumberFormat.GetPercentInstance()), "Wrong percent number format");
            NUnit.Framework.Assert.AreEqual("{0,number,percent}", format.ToPattern(), "Wrong percent number pattern");
            format.ApplyPattern("{0, number, integer}");
            IBM.ICU.Text.NumberFormat nf = IBM.ICU.Text.NumberFormat.GetInstance();
            nf.SetMaximumFractionDigits(0);
            nf.SetParseIntegerOnly(true);
            NUnit.Framework.Assert.IsTrue(format.GetFormats()[0].Equals(nf), "Wrong integer number format");
            NUnit.Framework.Assert.AreEqual("{0,number,integer}", format.ToPattern(), "Wrong integer number pattern");

            format.ApplyPattern("{0, number, {'#'}##0.0E0}");

            /*
             * TODO validate these assertions String actual =
             * ((DecimalFormat)(format.getFormats()[0])).toPattern();
             * assertEquals("Wrong pattern number format", "' {#}'##0.0E0", actual);
             * assertEquals("Wrong pattern number pattern",
             * "{0,number,' {#}'##0.0E0}", format.toPattern());
             */

            format.ApplyPattern("{0, choice,0#no|1#one|2#{1,number}}");
            NUnit.Framework.Assert.AreEqual("0.0#no|1.0#one|2.0#{1,number}", ((ILOG.J2CsMapping.Formatting.ChoiceFormat)format.GetFormats()[0]).ToPattern(), "Wrong choice format");
            NUnit.Framework.Assert.AreEqual("{0,choice,0.0#no|1.0#one|2.0#{1,number}}", format.ToPattern(), "Wrong choice pattern");
            NUnit.Framework.Assert.AreEqual("3.6", format.FormatObject(new Object[] { ((int)(2)), (float)(3.6d) }), "Wrong formatted choice");

            try
            {
                format.ApplyPattern("WRONG MESSAGE FORMAT {0,number,{}");
                NUnit.Framework.Assert.Fail("Expected IllegalArgumentException for invalid pattern");
            }
            catch (ArgumentException e)
            {
            }

            // Regression for HARMONY-65
            IBM.ICU.Text.MessageFormat mf = new IBM.ICU.Text.MessageFormat("{0,number,integer}");
            String badpattern             = "{0,number,#";

            try
            {
                mf.ApplyPattern(badpattern);
                NUnit.Framework.Assert.Fail("Assert 0: Failed to detect unmatched brackets.");
            }
            catch (ArgumentException e_0)
            {
                // expected
            }
        }