Skip to content

Commit debaa5e

Browse files
committed
Add test for #2288
1 parent d2f7316 commit debaa5e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.serialization.features.sealed
6+
7+
import kotlinx.serialization.*
8+
import kotlinx.serialization.json.*
9+
import kotlin.jvm.*
10+
import kotlin.test.*
11+
12+
class SealedInterfacesInlineSerialNameTest : JsonTestBase() {
13+
@Serializable
14+
data class Child1Value(
15+
val a: Int,
16+
val b: String
17+
)
18+
19+
@Serializable
20+
data class Child2Value(
21+
val c: Int,
22+
val d: String
23+
)
24+
25+
@Serializable
26+
sealed interface Parent
27+
28+
@Serializable
29+
@SerialName("child1")
30+
@JvmInline
31+
value class Child1(val value: Child1Value) : Parent
32+
33+
@Serializable
34+
@SerialName("child2")
35+
@JvmInline
36+
value class Child2(val value: Child2Value) : Parent
37+
38+
@Test
39+
@Ignore // https://github.com/Kotlin/kotlinx.serialization/issues/2288
40+
fun testSealedInterfaceInlineSerialName() {
41+
val messages = listOf(
42+
Child1(Child1Value(1, "one")),
43+
Child2(Child2Value(2, "two"))
44+
)
45+
assertJsonFormAndRestored(
46+
serializer(),
47+
messages,
48+
"""[{"type":"child1","a":1,"b":"one"},{"type":"child2","c":2,"d":"two"}]"""
49+
)
50+
}
51+
}

0 commit comments

Comments
 (0)