Search in sources :

Example 6 with MissingFormatWidthException

use of java.util.MissingFormatWidthException in project j2objc by google.

the class FormatterTest method test_formatLjava_lang_String$Ljava_lang_Object_FloatDoubleBigDecimalExceptionOrder.

/**
     * java.util.Formatter#format(String, Object...) for
     * Float/Double/BigDecimal exception throwing order
     */
public void test_formatLjava_lang_String$Ljava_lang_Object_FloatDoubleBigDecimalExceptionOrder() {
    Formatter f = null;
    /*
         * Summary: UnknownFormatConversionException >
         * MissingFormatWidthException > IllegalFormatFlagsException >
         * FormatFlagsConversionMismatchException >
         * IllegalFormatConversionException
         *
         */
    try {
        // compare FormatFlagsConversionMismatchException and
        // IllegalFormatConversionException
        f = new Formatter(Locale.US);
        f.format("%,e", (byte) 1);
        fail("should throw FormatFlagsConversionMismatchException");
    } catch (FormatFlagsConversionMismatchException e) {
    // expected
    }
    try {
        // compare IllegalFormatFlagsException and
        // FormatFlagsConversionMismatchException
        f = new Formatter(Locale.US);
        f.format("%+ ,e", 1f);
        fail("should throw IllegalFormatFlagsException");
    } catch (IllegalFormatFlagsException e) {
    // expected
    }
    try {
        // compare MissingFormatWidthException and
        // IllegalFormatFlagsException
        f = new Formatter(Locale.US);
        f.format("%+ -e", 1f);
        fail("should throw MissingFormatWidthException");
    } catch (MissingFormatWidthException e) {
    // expected
    }
    try {
        // compare UnknownFormatConversionException and
        // MissingFormatWidthException
        f = new Formatter(Locale.US);
        f.format("%-F", 1f);
        fail("should throw UnknownFormatConversionException");
    } catch (UnknownFormatConversionException e) {
    // expected
    }
}
Also used : UnknownFormatConversionException(java.util.UnknownFormatConversionException) FormatFlagsConversionMismatchException(java.util.FormatFlagsConversionMismatchException) Formatter(java.util.Formatter) IllegalFormatFlagsException(java.util.IllegalFormatFlagsException) MissingFormatWidthException(java.util.MissingFormatWidthException)

Aggregations

FormatFlagsConversionMismatchException (java.util.FormatFlagsConversionMismatchException)6 Formatter (java.util.Formatter)6 MissingFormatWidthException (java.util.MissingFormatWidthException)6 IllegalFormatFlagsException (java.util.IllegalFormatFlagsException)5 UnknownFormatConversionException (java.util.UnknownFormatConversionException)5 BigInteger (java.math.BigInteger)3 BigDecimal (java.math.BigDecimal)2 IllegalFormatConversionException (java.util.IllegalFormatConversionException)2 IllegalFormatPrecisionException (java.util.IllegalFormatPrecisionException)2 Date (java.util.Date)1 IllegalFormatCodePointException (java.util.IllegalFormatCodePointException)1