summaryrefslogtreecommitdiff
path: root/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonPolymorphicClassDescriptorTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonPolymorphicClassDescriptorTest.kt')
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonPolymorphicClassDescriptorTest.kt26
1 files changed, 26 insertions, 0 deletions
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonPolymorphicClassDescriptorTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonPolymorphicClassDescriptorTest.kt
new file mode 100644
index 00000000..b11e9dad
--- /dev/null
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/polymorphic/JsonPolymorphicClassDescriptorTest.kt
@@ -0,0 +1,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
+ )
+}