Skip to content

Commit

Permalink
Tests for generic descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
sandwwraith committed Sep 27, 2018
1 parent 17c6f37 commit b24f0fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ open class SerialClassDescImpl @JvmOverloads constructor(
if (other !is SerialClassDescImpl) return false

if (name != other.name) return false
if (descriptors != other.descriptors) return false
if (elementDescriptors() != other.elementDescriptors()) return false

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ data class Data1(@Optional val l: List<Int> = emptyList(), val s: String) {
@Serializable
data class Data2(@Optional val l: List<Int> = emptyList(), val s: String)


@Serializable data class Box<T>(val boxed: T)

@Serializable data class BoxHolder(val stringBox: Box<String>, val intBox: Box<Int>)

@Serializable
data class DataZoo(
@Transient val invisible: String = "",
Expand Down Expand Up @@ -105,4 +110,14 @@ class SchemaTest {

assertEquals(desc1.elementDescriptors(), desc2.elementDescriptors())
}

@Test
fun genericDescriptors() {
val boxes = BoxHolder.serializer().descriptor.elementDescriptors()
assertTrue(boxes[0].getElementDescriptor(0) is StringDescriptor)
assertTrue(boxes[1].getElementDescriptor(0) is IntDescriptor)
assertNotEquals(boxes[0], boxes[1])
val intBox = Box.serializer(IntSerializer).descriptor
assertEquals(intBox, boxes[1])
}
}

0 comments on commit b24f0fb

Please sign in to comment.