test/java/time/test/java/time/format/TestTextParser.java

Print this page




  42  *    and/or other materials provided with the distribution.
  43  *
  44  *  * Neither the name of JSR-310 nor the names of its contributors
  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 java.time.format.*;
  63 
  64 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
  65 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
  66 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
  67 import static org.testng.Assert.assertEquals;
  68 import static org.testng.Assert.assertTrue;
  69 
  70 import java.text.ParsePosition;
  71 import java.util.Locale;
  72 import java.time.format.DateTimeBuilder;
  73 import java.time.temporal.TemporalField;

  74 
  75 import org.testng.annotations.DataProvider;
  76 import org.testng.annotations.Test;
  77 
  78 /**
  79  * Test TextPrinterParser.
  80  */
  81 @Test(groups={"implementation"})
  82 public class TestTextParser extends AbstractTestPrinterParser {
  83 
  84     //-----------------------------------------------------------------------
  85     @DataProvider(name="error")
  86     Object[][] data_error() {
  87         return new Object[][] {
  88             {DAY_OF_WEEK, TextStyle.FULL, "Monday", -1, IndexOutOfBoundsException.class},
  89             {DAY_OF_WEEK, TextStyle.FULL, "Monday", 7, IndexOutOfBoundsException.class},
  90         };
  91     }
  92 
  93     @Test(dataProvider="error")
  94     public void test_parse_error(TemporalField field, TextStyle style, String text, int pos, Class<?> expected) {
  95         try {
  96             getFormatter(field, style).parseToBuilder(text, new ParsePosition(pos));
  97         } catch (RuntimeException ex) {
  98             assertTrue(expected.isInstance(ex));
  99         }
 100     }
 101 
 102     //-----------------------------------------------------------------------
 103     public void test_parse_midStr() throws Exception {
 104         ParsePosition pos = new ParsePosition(3);
 105         assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.FULL)
 106                      .parseToBuilder("XxxMondayXxx", pos)
 107                      .getLong(DAY_OF_WEEK), 1L);
 108         assertEquals(pos.getIndex(), 9);
 109     }
 110 
 111     public void test_parse_remainderIgnored() throws Exception {
 112         ParsePosition pos = new ParsePosition(0);
 113         assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.SHORT)
 114                      .parseToBuilder("Wednesday", pos)
 115                      .getLong(DAY_OF_WEEK), 3L);
 116         assertEquals(pos.getIndex(), 3);
 117     }
 118 
 119     //-----------------------------------------------------------------------
 120     public void test_parse_noMatch1() throws Exception {
 121         ParsePosition pos = new ParsePosition(0);
 122         DateTimeBuilder dtb =
 123             getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseToBuilder("Munday", pos);
 124         assertEquals(pos.getErrorIndex(), 0);

 125     }
 126 
 127     public void test_parse_noMatch2() throws Exception {
 128         ParsePosition pos = new ParsePosition(3);
 129         DateTimeBuilder dtb =
 130             getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseToBuilder("Monday", pos);
 131         assertEquals(pos.getErrorIndex(), 3);

 132     }
 133 
 134     public void test_parse_noMatch_atEnd() throws Exception {
 135         ParsePosition pos = new ParsePosition(6);
 136         DateTimeBuilder dtb =
 137             getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseToBuilder("Monday", pos);
 138         assertEquals(pos.getErrorIndex(), 6);

 139     }
 140 
 141     //-----------------------------------------------------------------------
 142     @DataProvider(name="parseText")
 143     Object[][] provider_text() {
 144         return new Object[][] {
 145             {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"},
 146             {DAY_OF_WEEK, TextStyle.FULL, 2, "Tuesday"},
 147             {DAY_OF_WEEK, TextStyle.FULL, 3, "Wednesday"},
 148             {DAY_OF_WEEK, TextStyle.FULL, 4, "Thursday"},
 149             {DAY_OF_WEEK, TextStyle.FULL, 5, "Friday"},
 150             {DAY_OF_WEEK, TextStyle.FULL, 6, "Saturday"},
 151             {DAY_OF_WEEK, TextStyle.FULL, 7, "Sunday"},
 152 
 153             {DAY_OF_WEEK, TextStyle.SHORT, 1, "Mon"},
 154             {DAY_OF_WEEK, TextStyle.SHORT, 2, "Tue"},
 155             {DAY_OF_WEEK, TextStyle.SHORT, 3, "Wed"},
 156             {DAY_OF_WEEK, TextStyle.SHORT, 4, "Thu"},
 157             {DAY_OF_WEEK, TextStyle.SHORT, 5, "Fri"},
 158             {DAY_OF_WEEK, TextStyle.SHORT, 6, "Sat"},


 167     }
 168 
 169     @DataProvider(name="parseNumber")
 170     Object[][] provider_number() {
 171         return new Object[][] {
 172             {DAY_OF_MONTH, TextStyle.FULL, 1, "1"},
 173             {DAY_OF_MONTH, TextStyle.FULL, 2, "2"},
 174             {DAY_OF_MONTH, TextStyle.FULL, 30, "30"},
 175             {DAY_OF_MONTH, TextStyle.FULL, 31, "31"},
 176 
 177             {DAY_OF_MONTH, TextStyle.SHORT, 1, "1"},
 178             {DAY_OF_MONTH, TextStyle.SHORT, 2, "2"},
 179             {DAY_OF_MONTH, TextStyle.SHORT, 30, "30"},
 180             {DAY_OF_MONTH, TextStyle.SHORT, 31, "31"},
 181        };
 182     }
 183 
 184     @Test(dataProvider="parseText")
 185     public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception {
 186         ParsePosition pos = new ParsePosition(0);
 187         assertEquals(getFormatter(field, style).parseToBuilder(input, pos).getLong(field), (long) value);
 188         assertEquals(pos.getIndex(), input.length());
 189     }
 190 
 191     @Test(dataProvider="parseNumber")
 192     public void test_parseNumber(TemporalField field, TextStyle style, int value, String input) throws Exception {
 193         ParsePosition pos = new ParsePosition(0);
 194         assertEquals(getFormatter(field, style).parseToBuilder(input, pos).getLong(field), (long) value);
 195         assertEquals(pos.getIndex(), input.length());
 196     }
 197 
 198     //-----------------------------------------------------------------------
 199     @Test(dataProvider="parseText")
 200     public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception {
 201         setCaseSensitive(true);
 202         ParsePosition pos = new ParsePosition(0);
 203         getFormatter(field, style).parseToBuilder(input.toUpperCase(), pos);
 204         assertEquals(pos.getErrorIndex(), 0);
 205     }
 206 
 207     @Test(dataProvider="parseText")
 208     public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception {
 209         setCaseSensitive(false);
 210         ParsePosition pos = new ParsePosition(0);
 211         assertEquals(getFormatter(field, style).parseToBuilder(input.toUpperCase(), pos).getLong(field), (long) value);
 212         assertEquals(pos.getIndex(), input.length());
 213     }
 214 
 215     //-----------------------------------------------------------------------
 216     @Test(dataProvider="parseText")
 217     public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception {
 218         setCaseSensitive(true);
 219         ParsePosition pos = new ParsePosition(0);
 220         getFormatter(field, style).parseToBuilder(input.toLowerCase(), pos);
 221         assertEquals(pos.getErrorIndex(), 0);
 222     }
 223 
 224     @Test(dataProvider="parseText")
 225     public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception {
 226         setCaseSensitive(false);
 227         ParsePosition pos = new ParsePosition(0);
 228         assertEquals(getFormatter(field, style).parseToBuilder(input.toLowerCase(), pos).getLong(field), (long) value);
 229         assertEquals(pos.getIndex(), input.length());
 230     }
 231 
 232     //-----------------------------------------------------------------------
 233     //-----------------------------------------------------------------------
 234     //-----------------------------------------------------------------------
 235     public void test_parse_full_strict_full_match() throws Exception {
 236         setStrict(true);
 237         ParsePosition pos = new ParsePosition(0);
 238         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseToBuilder("January", pos).getLong(MONTH_OF_YEAR), 1L);
 239         assertEquals(pos.getIndex(), 7);
 240     }
 241 
 242     public void test_parse_full_strict_short_noMatch() throws Exception {
 243         setStrict(true);
 244         ParsePosition pos = new ParsePosition(0);
 245         getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseToBuilder("Janua", pos);
 246         assertEquals(pos.getErrorIndex(), 0);
 247     }
 248 
 249     public void test_parse_full_strict_number_noMatch() throws Exception {
 250         setStrict(true);
 251         ParsePosition pos = new ParsePosition(0);
 252         getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseToBuilder("1", pos);
 253         assertEquals(pos.getErrorIndex(), 0);
 254     }
 255 
 256     //-----------------------------------------------------------------------
 257     public void test_parse_short_strict_full_match() throws Exception {
 258         setStrict(true);
 259         ParsePosition pos = new ParsePosition(0);
 260         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseToBuilder("January", pos).getLong(MONTH_OF_YEAR), 1L);
 261         assertEquals(pos.getIndex(), 3);
 262     }
 263 
 264     public void test_parse_short_strict_short_match() throws Exception {
 265         setStrict(true);
 266         ParsePosition pos = new ParsePosition(0);
 267         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseToBuilder("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
 268         assertEquals(pos.getIndex(), 3);
 269     }
 270 
 271     public void test_parse_short_strict_number_noMatch() throws Exception {
 272         setStrict(true);
 273         ParsePosition pos = new ParsePosition(0);
 274         getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseToBuilder("1", pos);
 275         assertEquals(pos.getErrorIndex(), 0);
 276     }
 277 
 278     //-----------------------------------------------------------------------
 279     public void test_parse_french_short_strict_full_noMatch() throws Exception {
 280         setStrict(true);
 281         ParsePosition pos = new ParsePosition(0);
 282         getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH)
 283                                                     .parseToBuilder("janvier", pos);
 284         assertEquals(pos.getErrorIndex(), 0);
 285     }
 286 
 287     public void test_parse_french_short_strict_short_match() throws Exception {
 288         setStrict(true);
 289         ParsePosition pos = new ParsePosition(0);
 290         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH)
 291                                                                  .parseToBuilder("janv.", pos)
 292                                                                  .getLong(MONTH_OF_YEAR),
 293                      1L);
 294         assertEquals(pos.getIndex(), 5);
 295     }
 296 
 297     //-----------------------------------------------------------------------
 298     public void test_parse_full_lenient_full_match() throws Exception {
 299         setStrict(false);
 300         ParsePosition pos = new ParsePosition(0);
 301         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseToBuilder("January.", pos).getLong(MONTH_OF_YEAR), 1L);
 302         assertEquals(pos.getIndex(), 7);
 303     }
 304 
 305     public void test_parse_full_lenient_short_match() throws Exception {
 306         setStrict(false);
 307         ParsePosition pos = new ParsePosition(0);
 308         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseToBuilder("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
 309         assertEquals(pos.getIndex(), 3);
 310     }
 311 
 312     public void test_parse_full_lenient_number_match() throws Exception {
 313         setStrict(false);
 314         ParsePosition pos = new ParsePosition(0);
 315         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseToBuilder("1", pos).getLong(MONTH_OF_YEAR), 1L);
 316         assertEquals(pos.getIndex(), 1);
 317     }
 318 
 319     //-----------------------------------------------------------------------
 320     public void test_parse_short_lenient_full_match() throws Exception {
 321         setStrict(false);
 322         ParsePosition pos = new ParsePosition(0);
 323         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseToBuilder("January", pos).getLong(MONTH_OF_YEAR), 1L);
 324         assertEquals(pos.getIndex(), 7);
 325     }
 326 
 327     public void test_parse_short_lenient_short_match() throws Exception {
 328         setStrict(false);
 329         ParsePosition pos = new ParsePosition(0);
 330         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseToBuilder("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
 331         assertEquals(pos.getIndex(), 3);
 332     }
 333 
 334     public void test_parse_short_lenient_number_match() throws Exception {
 335         setStrict(false);
 336         ParsePosition pos = new ParsePosition(0);
 337         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseToBuilder("1", pos).getLong(MONTH_OF_YEAR), 1L);
 338         assertEquals(pos.getIndex(), 1);
 339     }
 340 
 341 }


  42  *    and/or other materials provided with the distribution.
  43  *
  44  *  * Neither the name of JSR-310 nor the names of its contributors
  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     //-----------------------------------------------------------------------
 102     public void test_parse_midStr() throws Exception {
 103         ParsePosition pos = new ParsePosition(3);
 104         assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.FULL)
 105                      .parseUnresolved("XxxMondayXxx", pos)
 106                      .getLong(DAY_OF_WEEK), 1L);
 107         assertEquals(pos.getIndex(), 9);
 108     }
 109 
 110     public void test_parse_remainderIgnored() throws Exception {
 111         ParsePosition pos = new ParsePosition(0);
 112         assertEquals(getFormatter(DAY_OF_WEEK, TextStyle.SHORT)
 113                      .parseUnresolved("Wednesday", pos)
 114                      .getLong(DAY_OF_WEEK), 3L);
 115         assertEquals(pos.getIndex(), 3);
 116     }
 117 
 118     //-----------------------------------------------------------------------
 119     public void test_parse_noMatch1() throws Exception {
 120         ParsePosition pos = new ParsePosition(0);
 121         TemporalAccessor parsed =
 122             getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Munday", pos);
 123         assertEquals(pos.getErrorIndex(), 0);
 124         assertEquals(parsed, null);
 125     }
 126 
 127     public void test_parse_noMatch2() throws Exception {
 128         ParsePosition pos = new ParsePosition(3);
 129         TemporalAccessor parsed =
 130             getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos);
 131         assertEquals(pos.getErrorIndex(), 3);
 132         assertEquals(parsed, null);
 133     }
 134 
 135     public void test_parse_noMatch_atEnd() throws Exception {
 136         ParsePosition pos = new ParsePosition(6);
 137         TemporalAccessor parsed =
 138             getFormatter(DAY_OF_WEEK, TextStyle.FULL).parseUnresolved("Monday", pos);
 139         assertEquals(pos.getErrorIndex(), 6);
 140         assertEquals(parsed, null);
 141     }
 142 
 143     //-----------------------------------------------------------------------
 144     @DataProvider(name="parseText")
 145     Object[][] provider_text() {
 146         return new Object[][] {
 147             {DAY_OF_WEEK, TextStyle.FULL, 1, "Monday"},
 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"},


 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 
 251     public void test_parse_full_strict_number_noMatch() throws Exception {
 252         setStrict(true);
 253         ParsePosition pos = new ParsePosition(0);
 254         getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos);
 255         assertEquals(pos.getErrorIndex(), 0);
 256     }
 257 
 258     //-----------------------------------------------------------------------
 259     public void test_parse_short_strict_full_match() throws Exception {
 260         setStrict(true);
 261         ParsePosition pos = new ParsePosition(0);
 262         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("January", pos).getLong(MONTH_OF_YEAR), 1L);
 263         assertEquals(pos.getIndex(), 3);
 264     }
 265 
 266     public void test_parse_short_strict_short_match() throws Exception {
 267         setStrict(true);
 268         ParsePosition pos = new ParsePosition(0);
 269         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
 270         assertEquals(pos.getIndex(), 3);
 271     }
 272 
 273     public void test_parse_short_strict_number_noMatch() throws Exception {
 274         setStrict(true);
 275         ParsePosition pos = new ParsePosition(0);
 276         getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos);
 277         assertEquals(pos.getErrorIndex(), 0);
 278     }
 279 
 280     //-----------------------------------------------------------------------
 281     public void test_parse_french_short_strict_full_noMatch() throws Exception {
 282         setStrict(true);
 283         ParsePosition pos = new ParsePosition(0);
 284         getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH)
 285                                                     .parseUnresolved("janvier", pos);
 286         assertEquals(pos.getErrorIndex(), 0);
 287     }
 288 
 289     public void test_parse_french_short_strict_short_match() throws Exception {
 290         setStrict(true);
 291         ParsePosition pos = new ParsePosition(0);
 292         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).withLocale(Locale.FRENCH)
 293                                                                  .parseUnresolved("janv.", pos)
 294                                                                  .getLong(MONTH_OF_YEAR),
 295                      1L);
 296         assertEquals(pos.getIndex(), 5);
 297     }
 298 
 299     //-----------------------------------------------------------------------
 300     public void test_parse_full_lenient_full_match() throws Exception {
 301         setStrict(false);
 302         ParsePosition pos = new ParsePosition(0);
 303         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("January.", pos).getLong(MONTH_OF_YEAR), 1L);
 304         assertEquals(pos.getIndex(), 7);
 305     }
 306 
 307     public void test_parse_full_lenient_short_match() throws Exception {
 308         setStrict(false);
 309         ParsePosition pos = new ParsePosition(0);
 310         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("Janua", pos).getLong(MONTH_OF_YEAR), 1L);
 311         assertEquals(pos.getIndex(), 3);
 312     }
 313 
 314     public void test_parse_full_lenient_number_match() throws Exception {
 315         setStrict(false);
 316         ParsePosition pos = new ParsePosition(0);
 317         assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L);
 318         assertEquals(pos.getIndex(), 1);
 319     }
 320 
 321     //-----------------------------------------------------------------------
 322     public void test_parse_short_lenient_full_match() throws Exception {
 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 }