< prev index next >
test/jdk/java/time/test/java/time/format/TestFractionPrinterParser.java
Print this page
rev 56231 : [mq]: 8230136
*** 1,7 ****
/*
! * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 57,66 ****
--- 57,67 ----
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package test.java.time.format;
+ import static java.time.temporal.ChronoField.MILLI_OF_SECOND;
import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
*** 75,84 ****
--- 76,87 ----
import org.testng.annotations.Test;
import test.java.time.temporal.MockFieldValue;
/**
* Test FractionPrinterParser.
+ *
+ * @bug 8230136
*/
@Test
public class TestFractionPrinterParser extends AbstractTestPrinterParser {
private DateTimeFormatter getFormatter(TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) {
*** 329,338 ****
--- 332,359 ----
TemporalAccessor parsed = getFormatter(field, min, max, decimalPoint).parseUnresolved(text, ppos);
assertEquals(ppos.getErrorIndex(), expected);
assertEquals(parsed, null);
}
+ @DataProvider(name="ParseMinWidth")
+ Object[][] provider_parseMinWidth() {
+ return new Object[][] {
+ {MILLI_OF_SECOND, 3, 3, true, ".1x"},
+ {MILLI_OF_SECOND, 3, 3, true, ".12x"},
+ {MILLI_OF_SECOND, 3, 3, true, ".1234x"},
+ };
+ }
+
+ @Test(dataProvider="ParseMinWidth", expectedExceptions=DateTimeException.class)
+ public void test_parse_minWidth(TemporalField field, int min, int max, boolean decimalPoint, String text) throws Exception {
+ builder
+ .appendFraction(field, min, max, decimalPoint)
+ .appendLiteral("x")
+ .toFormatter(locale)
+ .parse(text);
+ }
+
//-----------------------------------------------------------------------
public void test_toString() throws Exception {
assertEquals(getFormatter(NANO_OF_SECOND, 3, 6, true).toString(), "Fraction(NanoOfSecond,3,6,DecimalPoint)");
}
< prev index next >