FileDocCategorySizeDatePackage
ScaledNumberFormatTest.javaAPI DocExample2347Wed Jun 16 19:00:58 BST 2004regress

ScaledNumberFormatTest

public class ScaledNumberFormatTest extends TestCase
A simple test case for ScaledNumberFormat parse and format

Fields Summary
com.darwinsys.util.ScaledNumberFormat
sf
data[]
sdata
data for scan (parse) test
data[]
ddata
data for format test.
Constructors Summary
Methods Summary
public voidtestFormatGood()


	   
		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 voidtestFormatThreeArgs()

		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 voidtestParseGood()


	     
		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());
		}