willowtreeapps / assertk

assertions for kotlin inspired by assertj
MIT License
776 stars 88 forks source link

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

Open JakeWharton opened 1 year ago

JakeWharton commented 1 year ago

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.

evant commented 1 year ago

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