alhudz commented on code in PR #1817:
URL: https://github.com/apache/commons-lang/pull/1817#discussion_r4280153888
##########
src/test/java/org/apache/commons/lang3/RandomUtilsTest.java:
##########
@@ -245,6 +245,19 @@ void testNextDouble(final RandomUtils ru) {
assertTrue(result < 42d);
}
+ /**
+ * Test a double range one ULP wide. A previous implementation could round
the scaled value up to the
+ * exclusive upper limit about half of the time.
+ */
+ @Test
+ void testNextDoubleExclusiveUpperBound() {
+ final double startInclusive = 10d;
+ final double endExclusive = Math.nextUp(startInclusive);
+ for (int i = 0; i < 1000; i++) {
+ assertEquals(startInclusive,
RandomUtils.nextDouble(startInclusive, endExclusive));
+ }
+ }
Review Comment:
Done in f434d34. The four exclusive-bound tests now loop over
`EXCLUSIVE_BOUND_TRIALS` instead of a literal `1000`. I left the existing `*
1000` in `testNextDouble`/`testNextFloat` alone because it is a separate
scaling factor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]