Search in sources :

Example 1 with MockFieldValue

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

the class TestNumberPrinter method test_pad_NORMAL.

@Test(dataProvider = "Pad")
public void test_pad_NORMAL(int minPad, int maxPad, long value, String result) throws Exception {
    try {
        getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), (value < 0 ? "-" + result : 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 2 with MockFieldValue

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

the class TestNumberPrinter method test_pad_ALWAYS.

@Test(dataProvider = "Pad")
public void test_pad_ALWAYS(int minPad, int maxPad, long value, String result) throws Exception {
    try {
        getFormatter(DAY_OF_MONTH, minPad, maxPad, SignStyle.ALWAYS).formatTo(new MockFieldValue(DAY_OF_MONTH, value), buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), (value < 0 ? "-" + result : "+" + 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 3 with MockFieldValue

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

the class TestReducedPrinter method test_pivot.

@Test(dataProvider = "Pivot")
public void test_pivot(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception {
    try {
        getFormatter0(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), result);
    } catch (DateTimeException ex) {
        if (result == null || value < 0) {
            assertEquals(ex.getMessage().contains(YEAR.toString()), true);
        } else {
            throw ex;
        }
    }
}
Also used : DateTimeException(java.time.DateTimeException) MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Example 4 with MockFieldValue

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

the class TestReducedPrinter method test_pivot_baseDate.

@Test(dataProvider = "Pivot")
public void test_pivot_baseDate(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception {
    try {
        getFormatterBaseDate(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), result);
    } catch (DateTimeException ex) {
        if (result == null || value < 0) {
            assertEquals(ex.getMessage().contains(YEAR.toString()), true);
        } else {
            throw ex;
        }
    }
}
Also used : DateTimeException(java.time.DateTimeException) MockFieldValue(test.java.time.temporal.MockFieldValue) Test(org.testng.annotations.Test)

Example 5 with MockFieldValue

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

the class TestFractionPrinterParser method test_print_seconds_noDecimalPoint.

@Test(dataProvider = "Seconds")
public void test_print_seconds_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception {
    getFormatter(SECOND_OF_MINUTE, minWidth, maxWidth, false).formatTo(new MockFieldValue(SECOND_OF_MINUTE, 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)

Aggregations

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