ICU-13151 Removing obsolete assertion from PluralFormat.java
X-SVN-Rev: 40199
This commit is contained in:
parent
2cea868e02
commit
95e854506a
@ -19,7 +19,6 @@ import java.util.Map;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.text.PluralRules.FixedDecimal;
|
||||
import com.ibm.icu.text.PluralRules.IFixedDecimal;
|
||||
import com.ibm.icu.text.PluralRules.Operand;
|
||||
import com.ibm.icu.text.PluralRules.PluralType;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import com.ibm.icu.util.ULocale.Category;
|
||||
@ -557,7 +556,6 @@ public class PluralFormat extends UFormat {
|
||||
@Override
|
||||
public String select(Object context, double number) {
|
||||
IFixedDecimal dec = (IFixedDecimal) context;
|
||||
assert dec.getPluralOperand(Operand.n) == Math.abs(number);
|
||||
return pluralRules.select(dec);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
package com.ibm.icu.dev.test.format;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -16,6 +17,7 @@ import org.junit.Test;
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.text.CurrencyPluralInfo;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.text.PluralFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
@ -26,13 +28,13 @@ import com.ibm.icu.util.ULocale;
|
||||
public class PluralFormatTest extends TestFmwk {
|
||||
private void helperTestRules(String localeIDs, String testPattern, Map<Integer,String> changes) {
|
||||
String[] locales = Utility.split(localeIDs, ',');
|
||||
|
||||
|
||||
// Create example outputs for all supported locales.
|
||||
/*
|
||||
System.out.println("\n" + localeIDs);
|
||||
String lastValue = (String) changes.get(new Integer(0));
|
||||
int lastNumber = 0;
|
||||
|
||||
int lastNumber = 0;
|
||||
|
||||
for (int i = 1; i < 199; ++i) {
|
||||
if (changes.get(new Integer(i)) != null) {
|
||||
if (lastNumber == i-1) {
|
||||
@ -51,7 +53,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
try {
|
||||
PluralFormat plf = new PluralFormat(new ULocale(locales[i]), testPattern);
|
||||
log("plf: " + plf);
|
||||
String expected = (String) changes.get(new Integer(0));
|
||||
String expected = changes.get(new Integer(0));
|
||||
for (int n = 0; n < 200; ++n) {
|
||||
String value = changes.get(n);
|
||||
if (value != null) {
|
||||
@ -65,7 +67,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestOneFormLocales() {
|
||||
String localeIDs = "ja,ko,tr,vi";
|
||||
@ -74,7 +76,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(0), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSingular1Locales() {
|
||||
String localeIDs = "bem,da,de,el,en,eo,es,et,fi,fo,he,it,nb,nl,nn,no,sv,af,bg,ca,eu,fur,fy,ha,ku,lb,ml," +
|
||||
@ -86,7 +88,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(2), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSingular01Locales() {
|
||||
String localeIDs = "ff,fr,kab,gu,mr,pa,pt,pt_PT,zu,bn";
|
||||
@ -96,7 +98,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(2), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestZeroSingularLocales() {
|
||||
String localeIDs = "lv";
|
||||
@ -121,7 +123,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
}
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSingularDual() {
|
||||
String localeIDs = "ga";
|
||||
@ -133,7 +135,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(3), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSingularZeroSome() {
|
||||
String localeIDs = "ro";
|
||||
@ -147,7 +149,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(120), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSpecial12_19() {
|
||||
String localeIDs = "lt";
|
||||
@ -167,7 +169,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
}
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestPaucalExcept11_14() {
|
||||
String localeIDs = "hr,sr,uk";
|
||||
@ -187,7 +189,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
}
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestPaucalRu() {
|
||||
String localeIDs = "ru";
|
||||
@ -205,7 +207,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
}
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
public <T> void put(int base, int start, int end, T value, Map<Integer, T> m) {
|
||||
for (int i = start; i <= end; ++i) {
|
||||
if (m.containsKey(base + i)) {
|
||||
@ -214,11 +216,11 @@ public class PluralFormatTest extends TestFmwk {
|
||||
m.put(base + i, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public <T> void put(int base, int start, T value, Map<Integer, T> m) {
|
||||
put(base, start, start, value, m);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestSingularPaucal() {
|
||||
String localeIDs = "cs,sk";
|
||||
@ -230,7 +232,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(5), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestPaucal1_234() {
|
||||
String localeIDs = "pl";
|
||||
@ -249,7 +251,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
}
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void TestPaucal1_2_34() {
|
||||
String localeIDs = "sl";
|
||||
@ -266,7 +268,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
changes.put(new Integer(105), "other");
|
||||
helperTestRules(localeIDs, testPattern, changes);
|
||||
}
|
||||
|
||||
|
||||
/* Tests the method public PluralRules getPluralRules() */
|
||||
@Test
|
||||
public void TestGetPluralRules() {
|
||||
@ -289,7 +291,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
errln("CurrencyPluralInfo.getLocale() was not suppose to return true " + "when passing a different ULocale");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Tests the method public void setLocale(ULocale loc) */
|
||||
@Test
|
||||
public void TestSetLocale() {
|
||||
@ -302,7 +304,7 @@ public class PluralFormatTest extends TestFmwk {
|
||||
errln("CurrencyPluralInfo.setLocale() was not suppose to return true when passing a different ULocale");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Tests the method public boolean equals(Object a) */
|
||||
@Test
|
||||
public void TestEquals(){
|
||||
@ -317,4 +319,14 @@ public class PluralFormatTest extends TestFmwk {
|
||||
errln("CurrencyPluralInfo.equals(Object) was not suppose to return true when comparing to an invalid object for string 0.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for http://bugs.icu-project.org/trac/ticket/13151 */
|
||||
@Test
|
||||
public void TestFractionRounding() {
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
|
||||
nf.setMaximumFractionDigits(0);
|
||||
PluralFormat pf = new PluralFormat(ULocale.ENGLISH, "one{#kg}other{#kgs}");
|
||||
pf.setNumberFormat(nf);
|
||||
assertEquals("1.2kg", "1kg", pf.format(1.2));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user