On Thu, 28 Aug 2025 13:04:53 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> test/jdk/javax/imageio/plugins/jpeg/JpegNegativeImageIndexTest.java line 52:
>> 
>>> 50: 
>>> 51:     private static void testMethod(String methodName,
>>> 52:                                    RunnableWithException method) {
>> 
>> The `testMethod` could return `true` to indicate success (the expected 
>> exception is caught), and `false` otherwise.
>> 
>> Then you combine the result of the method calls.
>
> I may suggest a streamed version of the test, see 
> [`JpegNegativeImageIndexTest.java`](https://github.com/openjdk/jdk/blob/c4cdd3b1e687f312898304e1144218e9aae47b7c/test/jdk/javax/imageio/plugins/jpeg/JpegNegativeImageIndexTest.java).
> 
> This version of test encapsulates both the method name and its lambda 
> expression in `TestMethod` record. Then `testMethod` executes the `Callable` 
> and returns `true` if `IndexOutOfBoundsException` is caught, otherwise it 
> prints an error message and returns `false`.
> 
> The main method creates a stream of `TestMethod` which contain all the tested 
> methods, maps these objects to a boolean value by using `testMethod` and 
> collects the results in a list. Then it is verified that the list contains 
> only `true`, if not an exception is thrown to fail the test.

Current state of test, i feel is more readable. So will keep it as it is.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26522#discussion_r2309319207

Reply via email to