@@ -18,6 +18,7 @@ package app.cash.zipline
1818import app.cash.zipline.internal.bridge.ThrowableSerializer
1919import assertk.assertThat
2020import assertk.assertions.isEqualTo
21+ import java.util.Locale.US
2122import kotlin.coroutines.cancellation.CancellationException
2223import kotlin.test.assertEquals
2324import kotlinx.serialization.json.Json
@@ -31,6 +32,17 @@ class ThrowableSerializerTest {
3132 contextual(Throwable ::class , ThrowableSerializer )
3233 }
3334 }
35+ private val newline: String
36+ private val newlineEscape: String
37+ init {
38+ if (" windows" in System .getProperty(" os.name" ).lowercase(US )) {
39+ newline = " \r\n "
40+ newlineEscape = " \\ r\\ n"
41+ } else {
42+ newline = " \n "
43+ newlineEscape = " \\ n"
44+ }
45+ }
3446
3547 @Test fun happyPath () {
3648 val exception = Exception (" boom" )
@@ -41,7 +53,7 @@ class ThrowableSerializerTest {
4153 val exceptionJson = """
4254 |{
4355 | "types": [],
44- | "stacktraceString": "java.lang.Exception: boom\n \tat ThrowableSerializerTest.goBoom(test.kt:5)"
56+ | "stacktraceString": "java.lang.Exception: boom$newlineEscape \tat ThrowableSerializerTest.goBoom(test.kt:5)"
4557 |}
4658 """ .trimMargin()
4759
@@ -53,10 +65,7 @@ class ThrowableSerializerTest {
5365 val decoded = json.decodeFromString(ThrowableSerializer , exceptionJson)
5466 assertEquals(ZiplineException ::class , decoded::class )
5567 assertEquals(
56- """
57- |java.lang.Exception: boom
58- |${' \t ' } at ThrowableSerializerTest.goBoom(test.kt:5)
59- """ .trimMargin(),
68+ " java.lang.Exception: boom$newline \t at ThrowableSerializerTest.goBoom(test.kt:5)" ,
6069 decoded.message,
6170 )
6271 }
0 commit comments