RFR: 8361715: (bf) Improve java/nio/Buffer/GetChars.java and migrate to JUnit [v7]
Brian Burkhalter
bpb at openjdk.org
Fri Jul 18 22:30:53 UTC 2025
On Fri, 18 Jul 2025 14:16:45 GMT, Brett Okken <duke at openjdk.org> wrote:
>> junit for CharSequence behavior of CharBuffer covering different CharBuffer implementations in various states (offset, position, limit)
>
> Brett Okken has updated the pull request incrementally with one additional commit since the last revision:
>
> adjust indexes used in tests to accomodate random values
test/jdk/java/nio/Buffer/CharBufferAsCharSequenceTest.java line 53:
> 51:
> 52: private static final Random RAND = RandomFactory.getRandom();
> 53: private static final int SIZE = 128 + RAND.nextInt(1024);
You might want to use the two-arg [nextInt](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/random/RandomGenerator.html#nextInt(int,int)) here instead of an addition, e.g., `RAND.nextInt(128,1152)`.
test/jdk/java/nio/Buffer/CharBufferAsCharSequenceTest.java line 66:
> 64: int mid = cb.capacity() >>> 1;
> 65: int start = RAND.nextInt(mid + 1); // from 0 to mid
> 66: int end = mid + RAND.nextInt(cb.capacity() - mid + 1); // from mid to capacity
Same comment as above concerning the two-arg `nextInt`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26282#discussion_r2216997121
PR Review Comment: https://git.openjdk.org/jdk/pull/26282#discussion_r2216997456
More information about the nio-dev
mailing list