Search in sources :

Example 6 with CompactDecimalFormat

use of android.icu.text.CompactDecimalFormat in project j2objc by google.

the class CompactDecimalFormatTest method checkLocale.

public void checkLocale(ULocale locale, CompactStyle style, Object[][] testData) {
    CompactDecimalFormat cdf = getCDFInstance(locale, style);
    checkCdf(locale + " (" + locale.getDisplayName(locale) + ") for ", cdf, testData);
}
Also used : CompactDecimalFormat(android.icu.text.CompactDecimalFormat)

Example 7 with CompactDecimalFormat

use of android.icu.text.CompactDecimalFormat in project j2objc by google.

the class CompactDecimalFormatTest method TestBug12688.

@Test
public void TestBug12688() {
    if (logKnownIssue("12688", "CDF fails for numbers less than 1 million in 'it'")) {
        return;
    }
    CompactDecimalFormat cdf;
    String result;
    cdf = CompactDecimalFormat.getInstance(ULocale.forLanguageTag("it"), CompactStyle.SHORT);
    result = cdf.format(new CurrencyAmount(123000, Currency.getInstance("EUR")));
    assertEquals("CDF should correctly format 123000 with currency in 'it'", "120000 €", result);
}
Also used : CompactDecimalFormat(android.icu.text.CompactDecimalFormat) CurrencyAmount(android.icu.util.CurrencyAmount) Test(org.junit.Test)

Example 8 with CompactDecimalFormat

use of android.icu.text.CompactDecimalFormat in project j2objc by google.

the class CompactDecimalFormatTest method checkCore.

private void checkCore(Map<String, String[][]> affixes, Map<String, String[]> currencyAffixes, long[] divisors, Object[][] testItems) {
    Collection<String> debugCreationErrors = new LinkedHashSet();
    CompactDecimalFormat cdf = new CompactDecimalFormat("#,###.00", DecimalFormatSymbols.getInstance(new ULocale("fr")), CompactStyle.SHORT, PluralRules.createRules("one: j is 1 or f is 1"), divisors, affixes, currencyAffixes, debugCreationErrors);
    if (debugCreationErrors.size() != 0) {
        for (String s : debugCreationErrors) {
            errln("Creation error: " + s);
        }
    } else {
        checkCdf("special cdf ", cdf, testItems);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ULocale(android.icu.util.ULocale) CompactDecimalFormat(android.icu.text.CompactDecimalFormat)

Example 9 with CompactDecimalFormat

use of android.icu.text.CompactDecimalFormat in project j2objc by google.

the class CompactDecimalFormatTest method TestEquals.

@Test
public void TestEquals() {
    CompactDecimalFormat cdf = CompactDecimalFormat.getInstance(ULocale.forLanguageTag("sw"), CompactStyle.SHORT);
    CompactDecimalFormat equalsCdf = CompactDecimalFormat.getInstance(ULocale.forLanguageTag("sw"), CompactStyle.SHORT);
    CompactDecimalFormat notEqualsCdf = CompactDecimalFormat.getInstance(ULocale.forLanguageTag("sw"), CompactStyle.LONG);
    assertEquals("equals", cdf, equalsCdf);
    assertNotEquals("not equals", cdf, notEqualsCdf);
}
Also used : CompactDecimalFormat(android.icu.text.CompactDecimalFormat) Test(org.junit.Test)

Example 10 with CompactDecimalFormat

use of android.icu.text.CompactDecimalFormat in project j2objc by google.

the class CompactDecimalFormatTest method TestFieldPosition.

@Test
public void TestFieldPosition() {
    CompactDecimalFormat cdf = getCDFInstance(ULocale.forLanguageTag("sw"), CompactStyle.SHORT);
    FieldPosition fp = new FieldPosition(0);
    StringBuffer sb = new StringBuffer();
    cdf.format(1234567f, sb, fp);
    assertEquals("fp string", "M1.2", sb.toString());
    assertEquals("fp start", 1, fp.getBeginIndex());
    assertEquals("fp end", 2, fp.getEndIndex());
}
Also used : FieldPosition(java.text.FieldPosition) CompactDecimalFormat(android.icu.text.CompactDecimalFormat) Test(org.junit.Test)

Aggregations

CompactDecimalFormat (android.icu.text.CompactDecimalFormat)13 Test (org.junit.Test)10 CurrencyAmount (android.icu.util.CurrencyAmount)3 ULocale (android.icu.util.ULocale)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 NotSerializableException (java.io.NotSerializableException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 AttributedCharacterIterator (java.text.AttributedCharacterIterator)1 FieldPosition (java.text.FieldPosition)1 ParsePosition (java.text.ParsePosition)1 LinkedHashSet (java.util.LinkedHashSet)1