Skip to content

Commit

Permalink
Use JsonTestBase and parametrizedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ionspin committed Jun 28, 2023
1 parent f28bc9b commit f44913b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.json.*
import kotlin.test.*

class JsonTreeDecoderPolymorphicTest {
class JsonTreeDecoderPolymorphicTest : JsonTestBase() {

@Serializable
sealed class Sealed
Expand All @@ -35,9 +35,9 @@ class JsonTreeDecoderPolymorphicTest {
)

@Test
fun testDecodingWhenClassContainsItself() {
val json = Json.encodeToJsonElement(outer as Sealed)
val decoded : Sealed = Json.decodeFromJsonElement(json)
fun testDecodingWhenClassContainsItself() = parametrizedTest { jsonTestingMode ->
val encoded = default.encodeToString(outer as Sealed, jsonTestingMode)
val decoded : Sealed = Json.decodeFromString(encoded, jsonTestingMode)
assertEquals(outer, decoded)
}
}

0 comments on commit f44913b

Please sign in to comment.