use of java.text.FieldPosition in project j2objc by google.
the class DecimalFormatTest method test_formatObject_errorCases.
public void test_formatObject_errorCases() {
DecimalFormat form = (DecimalFormat) NumberFormat.getInstance(Locale.US);
// IllegalArgumentException will be thrown out
try {
form.format(new Object(), new StringBuffer(), new FieldPosition(0));
fail("Should throw IAE");
} catch (IllegalArgumentException e) {
// expected
}
try {
form.format(null, new StringBuffer(), new FieldPosition(0));
fail("Should throw IAE");
} catch (IllegalArgumentException e) {
// expected
}
// NullPointerException will be thrown out.
try {
form.format(new Double(1.9), null, new FieldPosition(0));
fail("Should throw NPE");
} catch (NullPointerException e) {
// expected
}
try {
form.format(new Double(1.3), new StringBuffer(), null);
fail("Should throw NPE");
} catch (NullPointerException e) {
// expected
}
try {
form.format(new Object(), new StringBuffer(), new FieldPosition(0));
fail();
} catch (IllegalArgumentException expected) {
}
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_getBeginIndex.
/**
* @tests java.text.FieldPosition#getBeginIndex()
*/
public void test_getBeginIndex() {
// Test for method int java.text.FieldPosition.getBeginIndex()
FieldPosition fpos = new FieldPosition(1);
fpos.setEndIndex(3);
fpos.setBeginIndex(2);
assertEquals("getBeginIndex should have returned 2", 2, fpos.getBeginIndex());
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_equalsLjava_lang_Object.
/**
* @tests java.text.FieldPosition#equals(java.lang.Object)
*/
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.text.FieldPosition.equals(java.lang.Object)
FieldPosition fpos = new FieldPosition(1);
FieldPosition fpos1 = new FieldPosition(1);
assertTrue("Identical objects were not equal!", fpos.equals(fpos1));
FieldPosition fpos2 = new FieldPosition(2);
assertTrue("Objects with a different ID should not be equal!", !fpos.equals(fpos2));
fpos.setBeginIndex(1);
fpos1.setBeginIndex(2);
assertTrue("Objects with a different beginIndex were still equal!", !fpos.equals(fpos1));
fpos1.setBeginIndex(1);
fpos1.setEndIndex(2);
assertTrue("Objects with a different endIndex were still equal!", !fpos.equals(fpos1));
FieldPosition fpos3 = new FieldPosition(DateFormat.Field.ERA, 1);
assertTrue("Objects with a different attribute should not be equal!", !fpos.equals(fpos3));
FieldPosition fpos4 = new FieldPosition(DateFormat.Field.AM_PM, 1);
assertTrue("Objects with a different attribute should not be equal!", !fpos3.equals(fpos4));
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_setBeginIndexI.
public void test_setBeginIndexI() {
FieldPosition fpos = new FieldPosition(1);
fpos.setBeginIndex(2);
fpos.setEndIndex(3);
assertEquals("beginIndex should have been set to 2", 2, fpos.getBeginIndex());
fpos.setBeginIndex(Integer.MAX_VALUE);
assertEquals("beginIndex should have been set to Integer.MAX_VALUE", Integer.MAX_VALUE, fpos.getBeginIndex());
fpos.setBeginIndex(-1);
assertEquals("beginIndex should have been set to -1", -1, fpos.getBeginIndex());
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_getEndIndex.
/**
* @tests java.text.FieldPosition#getEndIndex()
*/
public void test_getEndIndex() {
// Test for method int java.text.FieldPosition.getEndIndex()
FieldPosition fpos = new FieldPosition(1);
fpos.setBeginIndex(2);
fpos.setEndIndex(3);
assertEquals("getEndIndex should have returned 3", 3, fpos.getEndIndex());
}
Aggregations