ICU-8610 Refactoring and renaming entities in Java implementation. Adding lots of comments. Should be ready to start C++ port.

X-SVN-Rev: 41141
This commit is contained in:
Shane Carr 2018-03-23 04:40:01 +00:00
parent fa6c8972ea
commit c725920cff
2 changed files with 905 additions and 832 deletions

View File

@ -3,7 +3,6 @@
package com.ibm.icu.dev.test.number;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -129,13 +128,12 @@ public class NumberSkeletonTest {
"scientific/ee",
"round-increment/xxx",
"round-increment/0.1.2",
"group-thousands/foo",
"currency/dummy",
"measure-unit/foo",
"integer-width/xxx",
"integer-width/0+",
"integer-width/+0#",
"scientific/foo"};
"scientific/foo" };
for (String cas : cases) {
try {
@ -161,6 +159,25 @@ public class NumberSkeletonTest {
}
}
@Test
public void unexpectedTokens() {
String[] cases = {
"group-thousands/foo",
"round-integer//ceiling group-off",
"round-integer//ceiling group-off",
"round-integer/ group-off",
"round-integer// group-off" };
for (String cas : cases) {
try {
NumberFormatter.fromSkeleton(cas);
fail();
} catch (SkeletonSyntaxException expected) {
assertTrue(expected.getMessage(), expected.getMessage().contains("Unexpected"));
}
}
}
@Test
public void stemsRequiringOption() {
String[] stems = { "round-increment", "currency", "measure-unit", "integer-width", };
@ -202,24 +219,14 @@ public class NumberSkeletonTest {
{ "round-integer group-off", "5142" },
{ "round-integer group-off", "5142" },
{ "round-integer/ceiling group-off", "5143" },
{ "round-integer//ceiling group-off", null },
{ "round-integer/ceiling group-off", "5143" },
{ "round-integer//ceiling group-off", null },
{ "round-integer/ group-off", null },
{ "round-integer// group-off", null } };
{ "round-integer/ceiling group-off", "5143" }, };
for (String[] cas : cases) {
String skeleton = cas[0];
String expected = cas[1];
try {
String actual = NumberFormatter.fromSkeleton(skeleton).locale(ULocale.ENGLISH)
.format(5142.3).toString();
assertEquals(skeleton, expected, actual);
} catch (SkeletonSyntaxException e) {
// Expected failure?
assertNull(skeleton, expected);
}
String actual = NumberFormatter.fromSkeleton(skeleton).locale(ULocale.ENGLISH).format(5142.3)
.toString();
assertEquals(skeleton, expected, actual);
}
}