assertk icon indicating copy to clipboard operation
assertk copied to clipboard

Detect when `toString` is the same but only newline characters differ

Open JakeWharton opened this issue 2 years ago • 1 comments

This can be a common occurrence with code generation where you have platform-specific golden files or strings as your expects, but platform-agnostic code generation that uses either CRLF or LF depending on the host. Since these render the same visually and will be the same source type, there is no way to tell what's wrong from the error message.

Truth does this, and it's glorious.

JakeWharton avatar Dec 08 '23 16:12 JakeWharton

The diff actually renders newline and tab characters, open to suggestions for improvements though https://github.com/willowtreeapps/assertk/blob/main/assertk/src/commonMain/kotlin/assertk/assertions/support/support.kt#L159 https://github.com/willowtreeapps/assertk/blob/main/assertk/src/commonTest/kotlin/test/assertk/assertions/StringTest.kt#L48

evant avatar Dec 08 '23 19:12 evant