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"); }
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"); }