Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1289)

Unified Diff: icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ModifierTest.java

Issue 335150043: Refreshing Number Parsing: ICU4J Base URL: svn+icussh://source.icu-project.org/repos/icu/trunk/
Patch Set: Replying to Andy feedback round one. See commit message. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ModifierTest.java
===================================================================
--- icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ModifierTest.java (revision 40724)
+++ icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/ModifierTest.java (working copy)
@@ -46,11 +46,20 @@
@Test
public void testSimpleModifier() {
String[] patterns = { "{0}", "X{0}Y", "XX{0}YYY", "{0}YY", "XX📺XX{0}" };
- Object[][] outputs = { { "", 0, 0 }, { "a📻bcde", 0, 0 }, { "a📻bcde", 4, 4 }, { "a📻bcde", 3, 5 } };
+ Object[][] outputs = {
+ { "", 0, 0 },
+ { "a📻bcde", 0, 0 },
+ { "a📻bcde", 4, 4 },
+ { "a📻bcde", 3, 5 } };
int[] prefixLens = { 0, 1, 2, 0, 6 };
- String[][] expectedCharFields = { { "|", "n" }, { "X|Y", "%n%" }, { "XX|YYY", "%%n%%%" }, { "|YY", "n%%" },
+ String[][] expectedCharFields = {
+ { "|", "n" },
+ { "X|Y", "%n%" },
+ { "XX|YYY", "%%n%%%" },
+ { "|YY", "n%%" },
{ "XX📺XX|", "%%%%%%n" } };
- String[][] expecteds = { { "", "XY", "XXYYY", "YY", "XX📺XX" },
+ String[][] expecteds = {
+ { "", "XY", "XXYYY", "YY", "XX📺XX" },
{ "a📻bcde", "XYa📻bcde", "XXYYYa📻bcde", "YYa📻bcde", "XX📺XXa📻bcde" },
{ "a📻bcde", "a📻bXYcde", "a📻bXXYYYcde", "a📻bYYcde", "a📻bXX📺XXcde" },
{ "a📻bcde", "a📻XbcYde", "a📻XXbcYYYde", "a📻bcYYde", "a📻XX📺XXbcde" } };
@@ -59,7 +68,11 @@
String compiledPattern = SimpleFormatterImpl
.compileToStringMinMaxArguments(pattern, new StringBuilder(), 1, 1);
Modifier mod = new SimpleModifier(compiledPattern, NumberFormat.Field.PERCENT, false);
- assertModifierEquals(mod, prefixLens[i], false, expectedCharFields[i][0], expectedCharFields[i][1]);
+ assertModifierEquals(mod,
+ prefixLens[i],
+ false,
+ expectedCharFields[i][0],
+ expectedCharFields[i][1]);
// Test strange insertion positions
for (int j = 0; j < outputs.length; j++) {
@@ -99,7 +112,9 @@
// Test custom patterns
// The following line means that the last char of the number should be a | (rather than a digit)
- symbols.setPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH, true, "[|]");
+ symbols.setPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH,
+ true,
+ "[|]");
suffix.append("XYZ", NumberFormat.Field.CURRENCY);
Modifier mod3 = new CurrencySpacingEnabledModifier(prefix, suffix, true, symbols);
assertModifierEquals(mod3, 3, true, "USD|\u00A0XYZ", "$$$nn$$$");
@@ -112,18 +127,18 @@
// If this test starts failing, please update the method #getUnicodeSet() in
// BOTH CurrencySpacingEnabledModifier.java AND in C++.
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(new ULocale("en-US"));
- assertEquals(
- "[:^S:]",
- dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_CURRENCY_MATCH, true));
- assertEquals(
- "[:^S:]",
- dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_CURRENCY_MATCH, false));
- assertEquals(
- "[:digit:]",
- dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH, true));
- assertEquals(
- "[:digit:]",
- dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH, false));
+ assertEquals("[:^S:]",
+ dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_CURRENCY_MATCH,
+ true));
+ assertEquals("[:^S:]",
+ dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_CURRENCY_MATCH,
+ false));
+ assertEquals("[:digit:]",
+ dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH,
+ true));
+ assertEquals("[:digit:]",
+ dfs.getPatternForCurrencySpacing(DecimalFormatSymbols.CURRENCY_SPC_SURROUNDING_MATCH,
+ false));
}
private void assertModifierEquals(
@@ -134,7 +149,12 @@
String expectedFields) {
NumberStringBuilder sb = new NumberStringBuilder();
sb.appendCodePoint('|', null);
- assertModifierEquals(mod, sb, expectedPrefixLength, expectedStrong, expectedChars, expectedFields);
+ assertModifierEquals(mod,
+ sb,
+ expectedPrefixLength,
+ expectedStrong,
+ expectedChars,
+ expectedFields);
}
private void assertModifierEquals(
@@ -150,8 +170,10 @@
assertEquals("Strong on " + sb, expectedStrong, mod.isStrong());
if (!(mod instanceof CurrencySpacingEnabledModifier)) {
assertEquals("Code point count equals actual code point count",
- sb.codePointCount() - oldCount, mod.getCodePointCount());
+ sb.codePointCount() - oldCount,
+ mod.getCodePointCount());
}
- assertEquals("<NumberStringBuilder [" + expectedChars + "] [" + expectedFields + "]>", sb.toDebugString());
+ assertEquals("<NumberStringBuilder [" + expectedChars + "] [" + expectedFields + "]>",
+ sb.toDebugString());
}
}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b