mirror of https://github.com/apache/lucene.git
LUCENE-8640: fixing DateRangePrefixTreeTest, accepting 0..59 minutes and seconds.
This commit is contained in:
parent
8e69d12dd7
commit
f543b4e1f4
|
@ -488,7 +488,7 @@ public class DateRangePrefixTree extends NumberRangePrefixTree {
|
||||||
checkDelimeter(str, offset-1, ':');
|
checkDelimeter(str, offset-1, ':');
|
||||||
//minute:
|
//minute:
|
||||||
|
|
||||||
parsedVal = parseAndCheck( str, offset, 1, 60);
|
parsedVal = parseAndCheck( str, offset, 0, 59);
|
||||||
cal.set(Calendar.MINUTE, parsedVal);
|
cal.set(Calendar.MINUTE, parsedVal);
|
||||||
offset += 3;
|
offset += 3;
|
||||||
if (lastOffset < offset)
|
if (lastOffset < offset)
|
||||||
|
@ -496,7 +496,7 @@ public class DateRangePrefixTree extends NumberRangePrefixTree {
|
||||||
checkDelimeter(str, offset-1, ':');
|
checkDelimeter(str, offset-1, ':');
|
||||||
//second:
|
//second:
|
||||||
|
|
||||||
parsedVal = parseAndCheck( str, offset, 1, 60);
|
parsedVal = parseAndCheck( str, offset, 0, 59);
|
||||||
cal.set(Calendar.SECOND, parsedVal);
|
cal.set(Calendar.SECOND, parsedVal);
|
||||||
offset += 3;
|
offset += 3;
|
||||||
if (lastOffset < offset)
|
if (lastOffset < offset)
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class DateRangePrefixTreeTest extends LuceneTestCase {
|
||||||
roundTrip(cal);
|
roundTrip(cal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToStringISO8601() {
|
public void testToStringISO8601() throws ParseException {
|
||||||
Calendar cal = tree.newCal();
|
Calendar cal = tree.newCal();
|
||||||
cal.setTimeInMillis(random().nextLong());
|
cal.setTimeInMillis(random().nextLong());
|
||||||
// create ZonedDateTime from the calendar, then get toInstant.toString which is the ISO8601 we emulate
|
// 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();
|
.toInstant().toString();
|
||||||
String resultToString = tree.toString(cal) + 'Z';
|
String resultToString = tree.toString(cal) + 'Z';
|
||||||
assertEquals(expectedISO8601, resultToString);
|
assertEquals(expectedISO8601, resultToString);
|
||||||
|
assertEquals(cal, tree.parseCalendar(expectedISO8601));
|
||||||
}
|
}
|
||||||
|
|
||||||
//copies from DateRangePrefixTree
|
//copies from DateRangePrefixTree
|
||||||
|
@ -211,7 +212,11 @@ public class DateRangePrefixTreeTest extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInvalidDateException() throws ParseException {
|
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, () -> {
|
expectThrows(ParseException.class, () -> {
|
||||||
tree.parseCalendar("2000-11T13");
|
tree.parseCalendar("2000-11T13");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue