On Fri, 30 Oct 2026 08:14:45 GMT, Tobias Hartmann <[email protected]> wrote:

> When writing a test, I noticed that `assertNull(42)` fails with  
> `assertEquals expected: 42 but was: null` instead of `assertNull: expected 
> null but was 42`. So I thought "Let's quickly fix that!". Well, I found and 
> fixed more issues in the process and also added proper testing.
> 
> Here's an overview:
> |  |  | Before | After |
> | --- | --- | --- | --- |
> | **1** | `assertNull(42)` | `assertEquals expected: 42 but was: null` | 
> `assertNull: expected null but was 42` |
> | **2** | `assertNotNull(null)` | `assertNotEquals: expected not equals but 
> was null` | `assertNotNull: expected non-null but was null` |
> | **3** | `assertEqualsByteArray(null, new byte[1])` | `NullPointerException` 
> while formatting the failure | `assertEqualsByteArray: expected null but was 
> 00` |
> | **4** | `assertLessThan(null, 42)` | `null: values must be non-null: <null> 
> , <42>` | `assertLessThan: values must be non-null: <null> , <42>` |
> 
> I put the explanations in-line with the changes.
> 
> Thanks,
> Tobias
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Thanks for the reviews, Marc and Manuel!

@marc-chevalier While I agree with your comments, it feels a bit out of scope 
and I'll leave it for a future enhancement :slightly_smiling_face:

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

PR Comment: https://git.openjdk.org/jdk/pull/33643#issuecomment-6520152531

Reply via email to