blob: b11e9dadf413cb3085af61e99a459a4b139bfb00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.serialization.json.polymorphic
import kotlinx.serialization.json.*
import kotlin.test.*
class JsonPolymorphicClassDescriptorTest : JsonTestBase() {
private val json = Json {
classDiscriminator = "class"
serializersModule = polymorphicTestModule
encodeDefaults = true
}
@Test
fun testPolymorphicProperties() = assertJsonFormAndRestored(
InnerBox.serializer(),
InnerBox(InnerImpl(42, "foo")),
"""{"base":{"class":"kotlinx.serialization.json.polymorphic.InnerImpl",""" +
""""field":42,"str":"foo","nullable":null}}""",
json
)
}
|