On Friday, 9 September 2022 at 14:35:33 UTC, Andrey Zherikov wrote:
I have bunch of `static assert(<condition>, <message>)` in my code and would like to validate that specific code triggers specific assert by checking what `<message>` is thrown.

It sounds like maybe your goal here is to test that attempting to compile a specific piece of code will result in a specific error message being *shown to the user*.

Unfortunately, the D compiler does not allow you to introspect on error messages, so it is impossible to write a `unittest` that covers this requirement. Instead, you will have to write an external script or program that attempts to compile a test program and checks the output for the expected error message.

Reply via email to