assertEquals("O", boolFormat3.format(falseValue));
}
public void testFormatThrowsException() {
FieldPosition pos = new FieldPosition(0);
StringBuffer sb = new StringBuffer();
try {
boolFormat.format(Integer.valueOf(7));
fail();
} catch (IllegalArgumentException e) {
// Expected.
}
boolFormat.format(null);
assertTrue(0 == pos.getBeginIndex());
assertTrue(0 == pos.getEndIndex());
try {
// StringBuffer is null.
boolFormat.format(trueValue, null, pos);
fail();
} catch (NullPointerException e) {
assertTrue(0 == pos.getBeginIndex());
assertTrue(0 == pos.getEndIndex());
}
try {
// FieldPosition is null.
boolFormat.format(trueValue, sb, null);
fail();
} catch (NullPointerException e) {
// OK.
}
pos = new FieldPosition(0);
sb = new StringBuffer();
// Object is null.
boolFormat.format(null, sb, pos);
assertTrue(0 == pos.getBeginIndex());
assertTrue(0 == pos.getEndIndex());
assertTrue(0 == sb.length());
pos = new FieldPosition(0);
try {
// Object is not instance of Boolean.
boolFormat.format(new Object(), new StringBuffer(), pos);
fail();
} catch (IllegalArgumentException e) {
assertTrue(0 == pos.getBeginIndex());
assertTrue(0 == pos.getEndIndex());
assertTrue(0 == sb.length());
}
}