}
// This tests PluralFormats used inside MessageFormats.
public void testPluralFormat() {
{
MessageFormat mfNum = new MessageFormat(
"{0, plural, one{C''est # fichier} other " +
"{Ce sont # fichiers}} dans la liste.",
new ULocale("fr"));
MessageFormat mfAlpha = new MessageFormat(
"{argument, plural, one{C''est # fichier} other {Ce " +
"sont # fichiers}} dans la liste.",
new ULocale("fr"));
Object objArray[] = {new Long(0)};
HashMap objMap = new HashMap();
objMap.put("argument", objArray[0]);
String result = mfNum.format(objArray);
if (!result.equals(mfAlpha.format(objMap))) {
errln("PluralFormat's output differs when using named " +
"arguments instead of numbers!");
}
if (!result.equals("C'est 0 fichier dans la liste.")) {
errln("PluralFormat produced wrong message string.");
}
}
{
MessageFormat mfNum = new MessageFormat (
"There {0, plural, one{is # zavod}few{are {0, " +
"number,###.0} zavoda} other{are # zavodov}} in the " +
"directory.",
new ULocale("ru"));
MessageFormat mfAlpha = new MessageFormat (
"There {argument, plural, one{is # zavod}few{" +
"are {argument, number,###.0} zavoda} other{are # " +
"zavodov}} in the directory.",
new ULocale("ru"));
Object objArray[] = {new Long(4)};
HashMap objMap = new HashMap();
objMap.put("argument", objArray[0]);
String result = mfNum.format(objArray);
if (!result.equals(mfAlpha.format(objMap))) {
errln("PluralFormat's output differs when using named " +
"arguments instead of numbers!");
}
if (!result.equals("There are 4,0 zavoda in the directory.")) {
errln("PluralFormat produced wrong message string.");