RFR: 8340493: Fix some Asserts failure messages

Weijun Wang weijun at openjdk.org
Tue Dec 17 00:55:39 UTC 2024


On Mon, 16 Dec 2024 22:31:36 GMT, Valerie Peng <valeriep at openjdk.org> wrote:

>> `Asserts.assertNotEquals` shows "expected 12345 to not equal 12345" which sounds redundant, just say "expected not equals but was 12345".
>> 
>> `Asserts.assertEqualsByteArray` uses the words "expected... to equal...". Modify it to follow the `assertEquals` style ""expected... but was...".
>
> test/lib/jdk/test/lib/Asserts.java line 288:
> 
>> 286:         if (Arrays.equals(lhs, rhs)) {
>> 287:             msg = Objects.toString(msg, "assertNotEqualsByteArray")
>> 288:                     + ": expected not equals but was " + HexFormat.of().formatHex(lhs);
> 
> Seems still a bit long and hard to read. How about just ": should not equal to "?

I think they have the same meaning, but I prefer mine because it aligns with the style used in other methods. It sounds more formal and explicitly states what was expected and what's the actual result.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21101#discussion_r1887756839


More information about the core-libs-dev mailing list