RFR: 8340493: Fix some Asserts failure messages
Valerie Peng
valeriep at openjdk.org
Mon Dec 16 22:35:37 UTC 2024
On Fri, 20 Sep 2024 00:33:39 GMT, Weijun Wang <weijun 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 "?
test/lib/jdk/test/lib/Asserts.java line 448:
> 446: if ((lhs == rhs) || (lhs != null && lhs.equals(rhs))) {
> 447: msg = Objects.toString(msg, "assertNotEquals")
> 448: + ": expected not equals but was " + Objects.toString(lhs);
Same comment as above `assertNotEqualsByteArray(byte[] lhs, byte[] rhs, String msg)`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21101#discussion_r1887663516
PR Review Comment: https://git.openjdk.org/jdk/pull/21101#discussion_r1887664410
More information about the core-libs-dev
mailing list