Skip to content

Commit 112ff41

Browse files
committed
Create random durations with positive nanoseconds
Previously, test code that generated random durations could create a duration with negative amount of nanoseconds. Such duration is now normalized by the database so that nanoseconds value is always in range from 0 to 999_999_999. This commit makes tests only create random durations with nanoseconds in that range. Otherwise some test assertions fail because they expect non-normalized value to be returned back.
1 parent 05c451a commit 112ff41

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

driver/src/test/java/org/neo4j/driver/v1/util/TemporalUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static ZonedDateTime randomZonedDateTimeWithZoneId()
8181
public static IsoDuration randomDuration()
8282
{
8383
int sign = random().nextBoolean() ? 1 : -1; // duration can be negative
84-
return new InternalIsoDuration( sign * randomInt(), sign * randomInt(), sign * randomInt(), sign * Math.abs( random( NANO_OF_SECOND ) ) );
84+
return new InternalIsoDuration( sign * randomInt(), sign * randomInt(), sign * randomInt(), Math.abs( random( NANO_OF_SECOND ) ) );
8585
}
8686

8787
private static ZonedDateTime randomZonedDateTime( ZoneId zoneId )

0 commit comments

Comments
 (0)