Search in sources :

Example 51 with FieldPosition

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) {
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) FieldPosition(java.text.FieldPosition)

Example 52 with FieldPosition

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());
}
Also used : FieldPosition(java.text.FieldPosition)

Example 53 with FieldPosition

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));
}
Also used : FieldPosition(java.text.FieldPosition)

Example 54 with FieldPosition

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());
}
Also used : FieldPosition(java.text.FieldPosition)

Example 55 with FieldPosition

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());
}
Also used : FieldPosition(java.text.FieldPosition)

Aggregations

FieldPosition (java.text.FieldPosition)100 Date (java.util.Date)31 SimpleDateFormat (java.text.SimpleDateFormat)28 DecimalFormat (java.text.DecimalFormat)12 NumberFormat (java.text.NumberFormat)12 ParsePosition (java.text.ParsePosition)12 IsoDateFormat (alma.acs.util.IsoDateFormat)9 Test (org.junit.Test)9 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)8 Format (java.text.Format)8 MessageFormat (java.text.MessageFormat)8 DateFormat (java.text.DateFormat)6 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)5 IOException (java.io.IOException)3 ParseException (java.text.ParseException)3 Calendar (java.util.Calendar)3 GregorianCalendar (java.util.GregorianCalendar)3 Vector (java.util.Vector)3 ExtendedDateFormat (org.jkiss.utils.time.ExtendedDateFormat)3 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)2