ScaledNumberFormatTestpublic class ScaledNumberFormatTest extends TestCase A simple test case for ScaledNumberFormat parse and format |
Fields Summary |
---|
com.darwinsys.util.ScaledNumberFormat | sf | data[] | sdatadata for scan (parse) test | data[] | ddatadata for format test. |
Methods Summary |
---|
public void | testFormatGood()
for (int i = 0; i < ddata.length; i++) {
try {
String expect = ddata[i].string;
String actual = sf.format(ddata[i].number);
System.out.println("Expect: " + expect + "; actual: " + actual);
assertEquals(expect, expect, actual);
} catch (Exception ex) {
System.out.println("ERROR IN FORMAT CASE " + i);
System.out.println(ddata[i] + " threw " + ex);
}
}
| public void | testFormatThreeArgs()
StringBuffer sb = new StringBuffer();
assertEquals("sb return", sb, sf.format("999999999", sb, null));
assertEquals("format3Args", "953M", sb.toString());
System.out.println("Format 3 args => " + sb.toString());
sb.setLength(0);
sf.format("", sb, null);
assertEquals("format3Args", "0B", sb.toString());
try {
sf.format(null, sb, null);
} catch (IllegalArgumentException ex) {
System.out.println("Caught expected IAE on null input");
}
| public void | testParseGood()
for (int i = 0; i<sdata.length; i++) {
Object o = sf.parseObject(sdata[i].string, null);
assertEquals(sdata[i].string, sdata[i].number, ((Long)o).longValue());
}
|
|