blob: 660d1ef1f6511802f23f13947d4bc263d92d82fd (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@file:Suppress("DEPRECATION_ERROR")
package kotlinx.serialization.test
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.internal.EnumSerializer
import kotlin.test.*
@Suppress("TestFunctionName")
internal inline fun <reified E : Enum<E>> EnumSerializer(serialName: String): EnumSerializer<E> =
EnumSerializer(serialName, enumValues())
fun SerialDescriptor.assertDescriptorEqualsTo(other: SerialDescriptor) {
assertEquals(serialName, other.serialName)
assertEquals(elementsCount, other.elementsCount)
assertEquals(isNullable, other.isNullable)
assertEquals(annotations, other.annotations)
assertEquals(kind, other.kind)
for (i in 0 until elementsCount) {
getElementDescriptor(i).assertDescriptorEqualsTo(other.getElementDescriptor(i))
val name = getElementName(i)
val otherName = other.getElementName(i)
assertEquals(name, otherName)
assertEquals(getElementAnnotations(i), other.getElementAnnotations(i))
assertEquals(name, otherName)
assertEquals(isElementOptional(i), other.isElementOptional(i))
}
}
inline fun noJs(test: () -> Unit) {
if (!isJs()) test()
}
inline fun noJsLegacy(test: () -> Unit) {
if (!isJsLegacy()) test()
}
inline fun jvmOnly(test: () -> Unit) {
if (isJvm()) test()
}
|