Skip to content

Commit fb85b38

Browse files
committed
add round-trip serialization test for instructionAddressAdjustment
1 parent e820132 commit fb85b38

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

sentry/src/test/java/io/sentry/protocol/SentryStackTraceSerializationTest.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import io.sentry.JsonSerializable
88
import java.io.StringReader
99
import java.io.StringWriter
1010
import kotlin.test.assertEquals
11+
import kotlin.test.assertTrue
1112
import org.junit.Test
1213
import org.mockito.kotlin.mock
1314

@@ -60,6 +61,30 @@ class SentryStackTraceSerializationTest {
6061
assertEquals(expectedJson, actualJson)
6162
}
6263

64+
@Test
65+
fun `instructionAddressAdjustment serializes and deserializes correctly`() {
66+
val testCases =
67+
listOf(
68+
SentryStackTrace.InstructionAddressAdjustment.AUTO to "auto",
69+
SentryStackTrace.InstructionAddressAdjustment.ALL to "all",
70+
SentryStackTrace.InstructionAddressAdjustment.ALL_BUT_FIRST to "all_but_first",
71+
SentryStackTrace.InstructionAddressAdjustment.NONE to "none",
72+
)
73+
74+
for ((enumValue, expectedJson) in testCases) {
75+
val stackTrace = SentryStackTrace().apply { instructionAddressAdjustment = enumValue }
76+
val json = serialize(stackTrace)
77+
78+
assertTrue(
79+
json.contains("\"instruction_addr_adjustment\":\"$expectedJson\""),
80+
"Expected $enumValue to serialize as \"$expectedJson\"",
81+
)
82+
83+
val deserialized = deserialize(json)
84+
assertEquals(enumValue, deserialized.instructionAddressAdjustment)
85+
}
86+
}
87+
6388
// Helper
6489

6590
private fun sanitizedFile(path: String): String =

0 commit comments

Comments
 (0)