| 1 32 package net.sf.retrotranslator.runtime.format; 33 34 import java.util.*; 35 import net.sf.retrotranslator.tests.BaseTestCase; 36 37 40 public class CharacterConversionTestCase extends BaseTestCase { 41 42 public void testFormat() throws Exception { 43 assertFormat("x", "%c", 'x'); 44 assertFormat("y", "%c", (byte) 'y'); 45 assertFormat("z", "%c", (short) 'z'); 46 assertFormat("i", "%c", (int) 'i'); 47 assertFormat("\uF123", "%c", '\uF123'); 48 assertFormat("\uD800\uDF00", "%c", 0x10300); 49 if (!System.getProperty("java.vm.version").startsWith("1.5")) { 50 assertFormatException(IllegalFormatCodePointException.class, "%c", (byte) '\u00F1'); 51 assertFormatException(IllegalFormatCodePointException.class, "%c", (short) '\uF123'); 52 assertFormatException(IllegalFormatCodePointException.class, "%c", 0x500000); 53 } 54 assertFormat(" null null", "%7c %1c", null, null); 55 assertFormat(" x", "%4c", 'x'); 56 assertFormat("y ", "%-3c", 'y'); 57 assertFormat(" z", "%3c", 'z'); 58 assertFormatException(MissingFormatWidthException.class, "%-c", 'x'); 59 assertFormatException(FormatFlagsConversionMismatchException.class, "%-#c", 'x'); 60 assertFormatException(FormatFlagsConversionMismatchException.class, "%#c", 'x'); 61 assertFormatException(IllegalFormatPrecisionException.class, "%#10.2c", 'x'); 62 assertFormatException(IllegalFormatPrecisionException.class, "%10.2c", 'x'); 63 } 64 65 } | Popular Tags |