LUCENE-8640: fixing DateRangePrefixTreeTest, accepting 0..59 minutes and seconds.

This commit is contained in:
Mikhail Khludnev 2019-01-28 11:14:34 +03:00
parent 8e69d12dd7
commit f543b4e1f4
2 changed files with 9 additions and 4 deletions

View File

@ -488,7 +488,7 @@ public class DateRangePrefixTree extends NumberRangePrefixTree {
checkDelimeter(str, offset-1, ':');
//minute:
parsedVal = parseAndCheck( str, offset, 1, 60);
parsedVal = parseAndCheck( str, offset, 0, 59);
cal.set(Calendar.MINUTE, parsedVal);
offset += 3;
if (lastOffset < offset)
@ -496,7 +496,7 @@ public class DateRangePrefixTree extends NumberRangePrefixTree {
checkDelimeter(str, offset-1, ':');
//second:
parsedVal = parseAndCheck( str, offset, 1, 60);
parsedVal = parseAndCheck( str, offset, 0, 59);
cal.set(Calendar.SECOND, parsedVal);
offset += 3;
if (lastOffset < offset)

View File

@ -94,7 +94,7 @@ public class DateRangePrefixTreeTest extends LuceneTestCase {
roundTrip(cal);
}
public void testToStringISO8601() {
public void testToStringISO8601() throws ParseException {
Calendar cal = tree.newCal();
cal.setTimeInMillis(random().nextLong());
// create ZonedDateTime from the calendar, then get toInstant.toString which is the ISO8601 we emulate
@ -110,6 +110,7 @@ public class DateRangePrefixTreeTest extends LuceneTestCase {
.toInstant().toString();
String resultToString = tree.toString(cal) + 'Z';
assertEquals(expectedISO8601, resultToString);
assertEquals(cal, tree.parseCalendar(expectedISO8601));
}
//copies from DateRangePrefixTree
@ -211,7 +212,11 @@ public class DateRangePrefixTreeTest extends LuceneTestCase {
}
public void testInvalidDateException() throws ParseException {
{
Calendar jurasic = tree.parseCalendar("-187183959-07-06T11:00:57.156");
assertEquals(187183960, jurasic.get(Calendar.YEAR));
assertEquals(0, jurasic.get(Calendar.ERA));
}
expectThrows(ParseException.class, () -> {
tree.parseCalendar("2000-11T13");
});