@Test public void writeFixedWidthInt() { out.writeFixedWidthInt(0, 3, (byte) '0'); out.writeCharacter(' '); out.writeFixedWidthInt(1, 3, (byte) '0'); out.writeCharacter(' '); out.writeFixedWidthInt(-1, 3, (byte) '0'); out.writeCharacter(' '); out.writeFixedWidthInt(123, 3, (byte) '0'); assertStreamEquals("000 001 -01 123"); }
@Test public void writeCharacter() { out.writeCharacter('a'); out.writeCharacter('b'); out.writeCharacter('c'); out.writeCharacter('0'); out.writeCharacter('9'); out.writeCharacter('-'); out.writeCharacter('£'); out.writeCharacter('グ'); out.writeCharacter('d'); assertStreamEquals("abc09-£グd"); }
@Test public void writeDouble() { out.writeDouble(3.14, 2); out.writeCharacter(' '); out.writeDouble(0, 2); out.writeCharacter(' '); out.writeDouble(2.133, 2); out.writeCharacter(' '); out.writeDouble(2.135, 2); out.writeCharacter(' '); out.writeDouble(2.136, 2); out.writeCharacter(' '); out.writeDouble(-2.133, 2); out.writeCharacter(' '); out.writeDouble(-2.1373, 2); out.writeCharacter(' '); out.writeDouble(10.01, 2); assertStreamEquals("3.14 0.00 2.13 2.14 2.14 -2.13 -2.14 10.01"); }
@Test public void writeFloat() { out.writeFloat(3.14f, 2); out.writeCharacter(' '); out.writeFloat(0f, 2); out.writeCharacter(' '); out.writeFloat(2.133f, 2); out.writeCharacter(' '); out.writeFloat(2.135f, 2); out.writeCharacter(' '); out.writeFloat(2.136f, 2); out.writeCharacter(' '); out.writeFloat(-2.133f, 2); out.writeCharacter(' '); out.writeFloat(-2.1373f, 2); out.writeCharacter(' '); out.writeFloat(10.01f, 2); assertStreamEquals("3.14 0.00 2.13 2.14 2.14 -2.13 -2.14 10.01"); }
@Test public void writeSmallCashMinor() { out.writeSmallCashMinorUnit(1030); out.writeCharacter(' '); out.writeSmallCashMinorUnit(422); out.writeCharacter(' '); out.writeSmallCashMinorUnit(0); out.writeCharacter(' '); out.writeSmallCashMinorUnit(26); out.writeCharacter(' '); out.writeSmallCashMinorUnit(-77); out.writeCharacter(' '); out.writeSmallCashMinorUnit(-101201); out.writeCharacter(' '); out.writeSmallCashMinorUnit(SmallCashType.MAX_VALUE); out.writeCharacter(' '); out.writeSmallCashMinorUnit(SmallCashType.MIN_VALUE); assertStreamEquals("103.0 42.2 0.0 2.6 -7.7 -10120.1 214748364.7 -214748364.8"); }
@Test public void writeSmallCashMajor() { out.writeSmallCashMajorUnit(1030); out.writeCharacter(' '); out.writeSmallCashMajorUnit(422); out.writeCharacter(' '); out.writeSmallCashMajorUnit(0); out.writeCharacter(' '); out.writeSmallCashMajorUnit(26); out.writeCharacter(' '); out.writeSmallCashMajorUnit(-77); out.writeCharacter(' '); out.writeSmallCashMajorUnit(-101201); out.writeCharacter(' '); out.writeSmallCashMajorUnit(SmallCashType.MAX_VALUE); out.writeCharacter(' '); out.writeSmallCashMajorUnit(SmallCashType.MIN_VALUE); assertStreamEquals("1.03 0.42 0.00 0.02 -0.07 -101.20 2147483.64 -2147483.64"); }
@Test public void writeBigCashMinor() { out.writeBigCashMinorUnit(10300); out.writeCharacter(' '); out.writeBigCashMinorUnit(4200); out.writeCharacter(' '); out.writeBigCashMinorUnit(0); out.writeCharacter(' '); out.writeBigCashMinorUnit(200); // test rounding out.writeCharacter(' '); out.writeBigCashMinorUnit(249); out.writeCharacter(' '); out.writeBigCashMinorUnit(250); out.writeCharacter(' '); out.writeBigCashMinorUnit(-700); out.writeCharacter(' '); out.writeBigCashMinorUnit(-749); out.writeCharacter(' '); out.writeBigCashMinorUnit(-750); out.writeCharacter(' '); out.writeBigCashMinorUnit(-1012000); out.writeCharacter(' '); out.writeBigCashMinorUnit(BigCashType.MAX_VALUE); out.writeCharacter(' '); out.writeBigCashMinorUnit(BigCashType.MIN_VALUE); assertStreamEquals( "103.00 42.00 0.00 2.00 2.49 2.50 -7.00 -7.49 -7.50 -10120.00 92233720368547758.07 -92233720368547758.08"); }
@Test public void writeBigCashMajor() { out.writeBigCashMajorUnit(10300); out.writeCharacter(' '); out.writeBigCashMajorUnit(4200); out.writeCharacter(' '); out.writeBigCashMajorUnit(0); out.writeCharacter(' '); out.writeBigCashMajorUnit(200); // test rounding out.writeCharacter(' '); out.writeBigCashMajorUnit(249); out.writeCharacter(' '); out.writeBigCashMajorUnit(250); out.writeCharacter(' '); out.writeBigCashMajorUnit(-700); out.writeCharacter(' '); out.writeBigCashMajorUnit(-749); out.writeCharacter(' '); out.writeBigCashMajorUnit(-750); out.writeCharacter(' '); out.writeBigCashMajorUnit(-1012000); out.writeCharacter(' '); out.writeBigCashMajorUnit(BigCashType.MAX_VALUE); out.writeCharacter(' '); out.writeBigCashMajorUnit(BigCashType.MIN_VALUE); assertStreamEquals( "1.03 0.42 0.00 0.02 0.02 0.02 -0.07 -0.07 -0.07 -101.20 922337203685477.58 -922337203685477.58"); }