Search in sources :

Example 6 with MockFieldValue

use of test.java.time.temporal.MockFieldValue in project jdk8u_jdk by JetBrains.

the class TestTextPrinter method test_format.

@Test(dataProvider = "print")
public void test_format(TemporalField field, TextStyle style, int value, String expected) throws Exception {
    getFormatter(field, style).formatTo(new MockFieldValue(field, value), buf);
    assertEquals(buf.toString(), expected);
}
Also used : MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Example 7 with MockFieldValue

use of test.java.time.temporal.MockFieldValue in project jdk8u_jdk by JetBrains.

the class TestFractionPrinterParser method test_print_nanos_noDecimalPoint.

@Test(dataProvider = "Nanos")
public void test_print_nanos_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception {
    getFormatter(NANO_OF_SECOND, minWidth, maxWidth, false).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf);
    if (result == null) {
        fail("Expected exception");
    }
    assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result));
}
Also used : MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Example 8 with MockFieldValue

use of test.java.time.temporal.MockFieldValue in project jdk8u_jdk by JetBrains.

the class TestFractionPrinterParser method test_print_nanos.

@Test(dataProvider = "Nanos")
public void test_print_nanos(int minWidth, int maxWidth, int value, String result) throws Exception {
    getFormatter(NANO_OF_SECOND, minWidth, maxWidth, true).formatTo(new MockFieldValue(NANO_OF_SECOND, value), buf);
    if (result == null) {
        fail("Expected exception");
    }
    assertEquals(buf.toString(), result);
}
Also used : MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Example 9 with MockFieldValue

use of test.java.time.temporal.MockFieldValue in project jdk8u_jdk by JetBrains.

the class TestNumberPrinter method test_pad_NEVER.

@Test(dataProvider = "Pad")
public void test_pad_NEVER(int minPad, int maxPad, long value, String result) throws Exception {
    try {
        getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), result);
    } catch (DateTimeException ex) {
        if (result != null) {
            throw ex;
        }
        assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true);
    }
}
Also used : DateTimeException(java.time.DateTimeException) MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Example 10 with MockFieldValue

use of test.java.time.temporal.MockFieldValue in project jdk8u_jdk by JetBrains.

the class TestFractionPrinterParser method test_print_seconds.

@Test(dataProvider = "Seconds")
public void test_print_seconds(int minWidth, int maxWidth, int value, String result) throws Exception {
    getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, true).formatTo(new MockFieldValue(SECOND_OF_MINUTE, value), buf);
    if (result == null) {
        fail("Expected exception");
    }
    assertEquals(buf.toString(), result);
}
Also used : MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)12 MockFieldValue (test.java.time.temporal.MockFieldValue)12 DateTimeException (java.time.DateTimeException)7