dirk.dittert
02/17/2025, 2:27 PMval data = readSomeData() // reads a file from /src/test/resources
val actual = mangle(data)
actual shouldBe """
line 1
line 2
""".trimIndent()
The problem is that line separators can be different between the file and Kotlin multiline strings. How to deal with that in the most convenient way possible?Klitos Kyriacou
02/17/2025, 2:43 PMactual.lines().shouldContainExactly("line 1", "line 2")
dirk.dittert
02/17/2025, 2:44 PMdirk.dittert
02/17/2025, 2:44 PMKlitos Kyriacou
02/17/2025, 2:53 PMtrimIndent
is that it swallows the last line terminator, so if your data ends with a newline, it won't match. With lines()
you get a blank last line.dirk.dittert
02/17/2025, 2:58 PMEmil Kantis
02/17/2025, 4:23 PMEmil Kantis
02/17/2025, 4:24 PMAlex Kuznetsov
02/17/2025, 4:58 PM