Search in sources :

Example 11 with SimpleFormatter

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

the class SimpleFormatterTest method TestFormatReplaceNoOptimizationLeadingArgumentUsedTwice.

@Test
public void TestFormatReplaceNoOptimizationLeadingArgumentUsedTwice() {
    SimpleFormatter fmt = SimpleFormatter.compile("{2}, {0}, {1} and {3} {2}");
    StringBuilder result = new StringBuilder("original");
    int[] offsets = new int[4];
    assertEquals("", "original, freddy, frog and by original", fmt.formatAndReplace(result, offsets, "freddy", "frog", result, "by").toString());
    int[] expectedOffsets = { 10, 18, 30, 27 };
    verifyOffsets(expectedOffsets, offsets);
}
Also used : SimpleFormatter(android.icu.text.SimpleFormatter) Test(org.junit.Test)

Example 12 with SimpleFormatter

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

the class SimpleFormatterTest method TestFormatReplaceNoOptimizationNoOffsets.

@Test
public void TestFormatReplaceNoOptimizationNoOffsets() {
    SimpleFormatter fmt = SimpleFormatter.compile("Arguments {0} and {1}");
    StringBuilder result = new StringBuilder("previous:");
    assertEquals("", "Arguments previous: and frog", fmt.formatAndReplace(result, null, result, "frog").toString());
}
Also used : SimpleFormatter(android.icu.text.SimpleFormatter) Test(org.junit.Test)

Aggregations

SimpleFormatter (android.icu.text.SimpleFormatter)12 Test (org.junit.Test)12 MessageFormat (android.icu.text.MessageFormat)1