45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
51 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
52 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
53 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
54 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
56 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 */
60 package test.java.time.format;
61
62 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
63 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
64 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
65 import static org.testng.Assert.assertEquals;
66 import static org.testng.Assert.assertTrue;
67
68 import java.text.ParsePosition;
69 import java.time.format.TextStyle;
70 import java.time.temporal.TemporalAccessor;
71 import java.time.temporal.TemporalField;
72 import java.util.Locale;
73
74 import org.testng.annotations.DataProvider;
75 import org.testng.annotations.Test;
76
77 /**
78 * Test TextPrinterParser.
79 */
80 @Test(groups={"implementation"})
81 public class TestTextParser extends AbstractTestPrinterParser {
82
83 //-----------------------------------------------------------------------
84 @DataProvider(name="error")
85 Object[][] data_error() {
86 return new Object[][] {
87 {DAY_OF_WEEK, TextStyle.FULL, "Monday", -1, IndexOutOfBoundsException.class},
88 {DAY_OF_WEEK, TextStyle.FULL, "Monday", 7, IndexOutOfBoundsException.class},
89 };
90 }
91
92 @Test(dataProvider="error")
93 public void test_parse_error(TemporalField field, TextStyle style, String text, int pos, Class<?> expected) {
94 try {
95 getFormatter(field, style).parseUnresolved(text, new ParsePosition(pos));
96 } catch (RuntimeException ex) {
97 assertTrue(expected.isInstance(ex));
98 }
99 }
100
101 //-----------------------------------------------------------------------
148 {DAY_OF_WEEK, TextStyle.FULL, 2, "Tuesday"},
149 {DAY_OF_WEEK, TextStyle.FULL, 3, "Wednesday"},
150 {DAY_OF_WEEK, TextStyle.FULL, 4, "Thursday"},
151 {DAY_OF_WEEK, TextStyle.FULL, 5, "Friday"},
152 {DAY_OF_WEEK, TextStyle.FULL, 6, "Saturday"},
153 {DAY_OF_WEEK, TextStyle.FULL, 7, "Sunday"},
154
155 {DAY_OF_WEEK, TextStyle.SHORT, 1, "Mon"},
156 {DAY_OF_WEEK, TextStyle.SHORT, 2, "Tue"},
157 {DAY_OF_WEEK, TextStyle.SHORT, 3, "Wed"},
158 {DAY_OF_WEEK, TextStyle.SHORT, 4, "Thu"},
159 {DAY_OF_WEEK, TextStyle.SHORT, 5, "Fri"},
160 {DAY_OF_WEEK, TextStyle.SHORT, 6, "Sat"},
161 {DAY_OF_WEEK, TextStyle.SHORT, 7, "Sun"},
162
163 {MONTH_OF_YEAR, TextStyle.FULL, 1, "January"},
164 {MONTH_OF_YEAR, TextStyle.FULL, 12, "December"},
165
166 {MONTH_OF_YEAR, TextStyle.SHORT, 1, "Jan"},
167 {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"},
168 };
169 }
170
171 @DataProvider(name="parseNumber")
172 Object[][] provider_number() {
173 return new Object[][] {
174 {DAY_OF_MONTH, TextStyle.FULL, 1, "1"},
175 {DAY_OF_MONTH, TextStyle.FULL, 2, "2"},
176 {DAY_OF_MONTH, TextStyle.FULL, 30, "30"},
177 {DAY_OF_MONTH, TextStyle.FULL, 31, "31"},
178
179 {DAY_OF_MONTH, TextStyle.SHORT, 1, "1"},
180 {DAY_OF_MONTH, TextStyle.SHORT, 2, "2"},
181 {DAY_OF_MONTH, TextStyle.SHORT, 30, "30"},
182 {DAY_OF_MONTH, TextStyle.SHORT, 31, "31"},
183 };
184 }
185
186 @Test(dataProvider="parseText")
187 public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception {
188 ParsePosition pos = new ParsePosition(0);
189 assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value);
190 assertEquals(pos.getIndex(), input.length());
191 }
192
193 @Test(dataProvider="parseNumber")
194 public void test_parseNumber(TemporalField field, TextStyle style, int value, String input) throws Exception {
195 ParsePosition pos = new ParsePosition(0);
196 assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value);
197 assertEquals(pos.getIndex(), input.length());
198 }
199
200 //-----------------------------------------------------------------------
201 @Test(dataProvider="parseText")
202 public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception {
203 setCaseSensitive(true);
204 ParsePosition pos = new ParsePosition(0);
205 getFormatter(field, style).parseUnresolved(input.toUpperCase(), pos);
206 assertEquals(pos.getErrorIndex(), 0);
207 }
208
209 @Test(dataProvider="parseText")
210 public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception {
211 setCaseSensitive(false);
212 ParsePosition pos = new ParsePosition(0);
213 assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(), pos).getLong(field), (long) value);
214 assertEquals(pos.getIndex(), input.length());
215 }
216
217 //-----------------------------------------------------------------------
218 @Test(dataProvider="parseText")
219 public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception {
220 setCaseSensitive(true);
221 ParsePosition pos = new ParsePosition(0);
222 getFormatter(field, style).parseUnresolved(input.toLowerCase(), pos);
223 assertEquals(pos.getErrorIndex(), 0);
224 }
225
226 @Test(dataProvider="parseText")
227 public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception {
228 setCaseSensitive(false);
229 ParsePosition pos = new ParsePosition(0);
230 assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(), pos).getLong(field), (long) value);
231 assertEquals(pos.getIndex(), input.length());
232 }
233
234 //-----------------------------------------------------------------------
235 //-----------------------------------------------------------------------
236 //-----------------------------------------------------------------------
237 public void test_parse_full_strict_full_match() throws Exception {
238 setStrict(true);
239 ParsePosition pos = new ParsePosition(0);
240 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L);
241 assertEquals(pos.getIndex(), 7);
242 }
243
244 public void test_parse_full_strict_short_noMatch() throws Exception {
245 setStrict(true);
246 ParsePosition pos = new ParsePosition(0);
247 getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos);
248 assertEquals(pos.getErrorIndex(), 0);
249 }
250
323 setStrict(false);
324 ParsePosition pos = new ParsePosition(0);
325 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L);
326 assertEquals(pos.getIndex(), 7);
327 }
328
329 public void test_parse_short_lenient_short_match() throws Exception {
330 setStrict(false);
331 ParsePosition pos = new ParsePosition(0);
332 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
333 assertEquals(pos.getIndex(), 3);
334 }
335
336 public void test_parse_short_lenient_number_match() throws Exception {
337 setStrict(false);
338 ParsePosition pos = new ParsePosition(0);
339 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L);
340 assertEquals(pos.getIndex(), 1);
341 }
342
343 }
|
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
51 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
52 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
53 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
54 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
56 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 */
60 package test.java.time.format;
61
62 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
63 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
64 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
65 import static java.time.temporal.IsoFields.QUARTER_OF_YEAR;
66 import static org.testng.Assert.assertEquals;
67 import static org.testng.Assert.assertTrue;
68
69 import java.text.ParsePosition;
70 import java.time.DayOfWeek;
71 import java.time.format.DateTimeFormatter;
72 import java.time.format.TextStyle;
73 import java.time.temporal.TemporalAccessor;
74 import java.time.temporal.TemporalField;
75 import java.util.Locale;
76
77 import org.testng.annotations.DataProvider;
78 import org.testng.annotations.Test;
79
80 /**
81 * Test TextPrinterParser.
82 */
83 @Test
84 public class TestTextParser extends AbstractTestPrinterParser {
85 static final Locale RUSSIAN = new Locale("ru");
86 static final Locale FINNISH = new Locale("fi");
87
88 //-----------------------------------------------------------------------
89 @DataProvider(name="error")
90 Object[][] data_error() {
91 return new Object[][] {
92 {DAY_OF_WEEK, TextStyle.FULL, "Monday", -1, IndexOutOfBoundsException.class},
93 {DAY_OF_WEEK, TextStyle.FULL, "Monday", 7, IndexOutOfBoundsException.class},
94 };
95 }
96
97 @Test(dataProvider="error")
98 public void test_parse_error(TemporalField field, TextStyle style, String text, int pos, Class<?> expected) {
99 try {
100 getFormatter(field, style).parseUnresolved(text, new ParsePosition(pos));
101 } catch (RuntimeException ex) {
102 assertTrue(expected.isInstance(ex));
103 }
104 }
105
106 //-----------------------------------------------------------------------
153 {DAY_OF_WEEK, TextStyle.FULL, 2, "Tuesday"},
154 {DAY_OF_WEEK, TextStyle.FULL, 3, "Wednesday"},
155 {DAY_OF_WEEK, TextStyle.FULL, 4, "Thursday"},
156 {DAY_OF_WEEK, TextStyle.FULL, 5, "Friday"},
157 {DAY_OF_WEEK, TextStyle.FULL, 6, "Saturday"},
158 {DAY_OF_WEEK, TextStyle.FULL, 7, "Sunday"},
159
160 {DAY_OF_WEEK, TextStyle.SHORT, 1, "Mon"},
161 {DAY_OF_WEEK, TextStyle.SHORT, 2, "Tue"},
162 {DAY_OF_WEEK, TextStyle.SHORT, 3, "Wed"},
163 {DAY_OF_WEEK, TextStyle.SHORT, 4, "Thu"},
164 {DAY_OF_WEEK, TextStyle.SHORT, 5, "Fri"},
165 {DAY_OF_WEEK, TextStyle.SHORT, 6, "Sat"},
166 {DAY_OF_WEEK, TextStyle.SHORT, 7, "Sun"},
167
168 {MONTH_OF_YEAR, TextStyle.FULL, 1, "January"},
169 {MONTH_OF_YEAR, TextStyle.FULL, 12, "December"},
170
171 {MONTH_OF_YEAR, TextStyle.SHORT, 1, "Jan"},
172 {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"},
173
174 {QUARTER_OF_YEAR, TextStyle.FULL, 1, "1st quarter"},
175 {QUARTER_OF_YEAR, TextStyle.FULL, 2, "2nd quarter"},
176 {QUARTER_OF_YEAR, TextStyle.FULL, 3, "3rd quarter"},
177 {QUARTER_OF_YEAR, TextStyle.FULL, 4, "4th quarter"},
178
179 {QUARTER_OF_YEAR, TextStyle.SHORT, 1, "Q1"},
180 {QUARTER_OF_YEAR, TextStyle.SHORT, 2, "Q2"},
181 {QUARTER_OF_YEAR, TextStyle.SHORT, 3, "Q3"},
182 {QUARTER_OF_YEAR, TextStyle.SHORT, 4, "Q4"},
183
184 {QUARTER_OF_YEAR, TextStyle.NARROW, 1, "1"},
185 {QUARTER_OF_YEAR, TextStyle.NARROW, 2, "2"},
186 {QUARTER_OF_YEAR, TextStyle.NARROW, 3, "3"},
187 {QUARTER_OF_YEAR, TextStyle.NARROW, 4, "4"},
188 };
189 }
190
191 @DataProvider(name="parseNumber")
192 Object[][] provider_number() {
193 return new Object[][] {
194 {DAY_OF_MONTH, TextStyle.FULL, 1, "1"},
195 {DAY_OF_MONTH, TextStyle.FULL, 2, "2"},
196 {DAY_OF_MONTH, TextStyle.FULL, 30, "30"},
197 {DAY_OF_MONTH, TextStyle.FULL, 31, "31"},
198
199 {DAY_OF_MONTH, TextStyle.SHORT, 1, "1"},
200 {DAY_OF_MONTH, TextStyle.SHORT, 2, "2"},
201 {DAY_OF_MONTH, TextStyle.SHORT, 30, "30"},
202 {DAY_OF_MONTH, TextStyle.SHORT, 31, "31"},
203 };
204 }
205
206 // Test data is dependent on localized resources.
207 @DataProvider(name="parseStandaloneText")
208 Object[][] providerStandaloneText() {
209 // Locale, TemporalField, TextStyle, expected value, input text
210 return new Object[][] {
211 {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, 1, "\u042f\u043d\u0432\u0430\u0440\u044c"},
212 {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, 12, "\u0414\u0435\u043a\u0430\u0431\u0440\u044c"},
213 {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, 1, "\u042f\u043d\u0432."},
214 {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, 12, "\u0414\u0435\u043a."},
215 {FINNISH, DAY_OF_WEEK, TextStyle.FULL_STANDALONE, 2, "tiistai"},
216 {FINNISH, DAY_OF_WEEK, TextStyle.SHORT_STANDALONE, 2, "ti"},
217 };
218 }
219
220 @DataProvider(name="parseDayOfWeekText")
221 Object[][] providerDayOfWeekData() {
222 return new Object[][] {
223 // Locale, pattern, input text, expected DayOfWeek
224 {Locale.US, "e", "1", DayOfWeek.SUNDAY},
225 {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
226 {Locale.US, "c", "1", DayOfWeek.SUNDAY},
227
228 {Locale.UK, "e", "1", DayOfWeek.MONDAY},
229 {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
230 {Locale.UK, "c", "1", DayOfWeek.MONDAY},
231 };
232 }
233
234 // Test data is dependent on localized resources.
235 @DataProvider(name="parseLenientText")
236 Object[][] providerLenientText() {
237 // Locale, TemporalField, expected value, input text
238 return new Object[][] {
239 {RUSSIAN, MONTH_OF_YEAR, 1, "\u044f\u043d\u0432\u0430\u0440\u044f"}, // full format
240 {RUSSIAN, MONTH_OF_YEAR, 1, "\u042f\u043d\u0432\u0430\u0440\u044c"}, // full standalone
241 {RUSSIAN, MONTH_OF_YEAR, 1, "\u044f\u043d\u0432"}, // short format
242 {RUSSIAN, MONTH_OF_YEAR, 1, "\u042f\u043d\u0432."}, // short standalone
243 };
244 }
245
246 @Test(dataProvider="parseText")
247 public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception {
248 ParsePosition pos = new ParsePosition(0);
249 assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value);
250 assertEquals(pos.getIndex(), input.length());
251 }
252
253 @Test(dataProvider="parseNumber")
254 public void test_parseNumber(TemporalField field, TextStyle style, int value, String input) throws Exception {
255 ParsePosition pos = new ParsePosition(0);
256 assertEquals(getFormatter(field, style).parseUnresolved(input, pos).getLong(field), (long) value);
257 assertEquals(pos.getIndex(), input.length());
258 }
259
260 @Test(dataProvider="parseStandaloneText")
261 public void test_parseStandaloneText(Locale locale, TemporalField field, TextStyle style, int expectedValue, String input) {
262 DateTimeFormatter formatter = getFormatter(field, style).withLocale(locale);
263 ParsePosition pos = new ParsePosition(0);
264 assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue);
265 assertEquals(pos.getIndex(), input.length());
266 }
267
268 @Test(dataProvider="parseDayOfWeekText")
269 public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) {
270 DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale);
271 ParsePosition pos = new ParsePosition(0);
272 assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected);
273 assertEquals(pos.getIndex(), input.length());
274 }
275
276 //-----------------------------------------------------------------------
277 @Test(dataProvider="parseText")
278 public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception {
279 if (input.equals(input.toUpperCase(Locale.ROOT))) {
280 // Skip if the given input is all upper case (e.g., "Q1")
281 return;
282 }
283 setCaseSensitive(true);
284 ParsePosition pos = new ParsePosition(0);
285 getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos);
286 assertEquals(pos.getErrorIndex(), 0);
287 }
288
289 @Test(dataProvider="parseText")
290 public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception {
291 setCaseSensitive(false);
292 ParsePosition pos = new ParsePosition(0);
293 assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field), (long) value);
294 assertEquals(pos.getIndex(), input.length());
295 }
296
297 //-----------------------------------------------------------------------
298 @Test(dataProvider="parseText")
299 public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception {
300 if (input.equals(input.toLowerCase(Locale.ROOT))) {
301 // Skip if the given input is all lower case (e.g., "1st quarter")
302 return;
303 }
304 setCaseSensitive(true);
305 ParsePosition pos = new ParsePosition(0);
306 getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos);
307 assertEquals(pos.getErrorIndex(), 0);
308 }
309
310 @Test(dataProvider="parseText")
311 public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception {
312 setCaseSensitive(false);
313 ParsePosition pos = new ParsePosition(0);
314 assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field), (long) value);
315 assertEquals(pos.getIndex(), input.length());
316 }
317
318 //-----------------------------------------------------------------------
319 //-----------------------------------------------------------------------
320 //-----------------------------------------------------------------------
321 public void test_parse_full_strict_full_match() throws Exception {
322 setStrict(true);
323 ParsePosition pos = new ParsePosition(0);
324 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L);
325 assertEquals(pos.getIndex(), 7);
326 }
327
328 public void test_parse_full_strict_short_noMatch() throws Exception {
329 setStrict(true);
330 ParsePosition pos = new ParsePosition(0);
331 getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos);
332 assertEquals(pos.getErrorIndex(), 0);
333 }
334
407 setStrict(false);
408 ParsePosition pos = new ParsePosition(0);
409 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L);
410 assertEquals(pos.getIndex(), 7);
411 }
412
413 public void test_parse_short_lenient_short_match() throws Exception {
414 setStrict(false);
415 ParsePosition pos = new ParsePosition(0);
416 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
417 assertEquals(pos.getIndex(), 3);
418 }
419
420 public void test_parse_short_lenient_number_match() throws Exception {
421 setStrict(false);
422 ParsePosition pos = new ParsePosition(0);
423 assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L);
424 assertEquals(pos.getIndex(), 1);
425 }
426
427 @Test(dataProvider="parseLenientText")
428 public void test_parseLenientText(Locale locale, TemporalField field, int expectedValue, String input) {
429 setStrict(false);
430 ParsePosition pos = new ParsePosition(0);
431 DateTimeFormatter formatter = getFormatter(field).withLocale(locale);
432 assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue);
433 assertEquals(pos.getIndex(), input.length());
434 }
435
436 }
|