use of java.text.FieldPosition in project j2objc by google.
the class DecimalFormatTest method test_setGroupingUsed.
public void test_setGroupingUsed() {
DecimalFormat format = new DecimalFormat();
StringBuffer buf = new StringBuffer();
format.setGroupingUsed(false);
format.format(new Long(1970), buf, new FieldPosition(0));
assertEquals("1970", buf.toString());
assertFalse(format.isGroupingUsed());
format.format(new Long(1970), buf, new FieldPosition(0));
assertEquals("19701970", buf.toString());
assertFalse(format.isGroupingUsed());
format.setGroupingUsed(true);
format.format(new Long(1970), buf, new FieldPosition(0));
assertEquals("197019701,970", buf.toString());
assertTrue(format.isGroupingUsed());
}
use of java.text.FieldPosition in project j2objc by google.
the class MessageFormatTest method test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition.
public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
new Support_MessageFormat("test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition").t_format_with_FieldPosition();
String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} hamburger{2,choice,1#|1<s}.";
MessageFormat format = new MessageFormat(pattern, Locale.US);
Object[] objects = new Object[] { "", new Integer(3), 8, "" };
try {
format.format(objects, new StringBuffer(), new FieldPosition(DateFormat.Field.AM_PM));
fail();
} catch (IllegalArgumentException expected) {
}
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_ConstructorLjava_text_Format$Field.
/**
* @tests java.text.FieldPosition#FieldPosition(java.text.Format$Field)
*/
public void test_ConstructorLjava_text_Format$Field() {
// Test for constructor java.text.FieldPosition(Format.Field)
FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH);
assertSame("Constructor failed to set field attribute!", DateFormat.Field.MONTH, fpos.getFieldAttribute());
assertEquals("Test1: Constructor failed to set field identifier!", -1, fpos.getField());
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_ConstructorI.
/**
* @tests java.text.FieldPosition#FieldPosition(int)
*/
public void test_ConstructorI() {
// Test for constructor java.text.FieldPosition(int)
FieldPosition fpos = new FieldPosition(DateFormat.MONTH_FIELD);
assertEquals("Test1: Constructor failed to set field identifier!", DateFormat.MONTH_FIELD, fpos.getField());
assertNull("Constructor failed to set field attribute!", fpos.getFieldAttribute());
}
use of java.text.FieldPosition in project j2objc by google.
the class FieldPositionTest method test_toString.
/**
* @tests java.text.FieldPosition#toString()
*/
public void test_toString() {
// Test for method java.lang.String java.text.FieldPosition.toString()
FieldPosition fpos = new FieldPosition(1);
fpos.setBeginIndex(2);
fpos.setEndIndex(3);
assertEquals("ToString returned the wrong value:", "java.text.FieldPosition[field=1,attribute=null,beginIndex=2,endIndex=3]", fpos.toString());
FieldPosition fpos2 = new FieldPosition(DateFormat.Field.ERA);
fpos2.setBeginIndex(4);
fpos2.setEndIndex(5);
assertEquals("ToString returned the wrong value:", "java.text.FieldPosition[field=-1,attribute=" + DateFormat.Field.ERA + ",beginIndex=4,endIndex=5]", fpos2.toString());
}
Aggregations