summaryrefslogtreecommitdiff
path: root/guide/test/SerializersTest.kt
blob: 0871b829414c57bef6efec91de92a7daddf2fca4 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// This file was automatically generated from serializers.md by Knit tool. Do not edit.
package example.test

import org.junit.Test
import kotlinx.knit.test.*

class SerializersTest {
    @Test
    fun testExampleSerializer01() {
        captureOutput("ExampleSerializer01") { example.exampleSerializer01.main() }.verifyOutputLines(
            "{\"rgb\":65280}"
        )
    }

    @Test
    fun testExampleSerializer02() {
        captureOutput("ExampleSerializer02") { example.exampleSerializer02.main() }.verifyOutputLines(
            "Color(rgb: kotlin.Int)"
        )
    }

    @Test
    fun testExampleSerializer03() {
        captureOutput("ExampleSerializer03") { example.exampleSerializer03.main() }.verifyOutputLines(
            "Box(contents: Color)"
        )
    }

    @Test
    fun testExampleSerializer04() {
        captureOutput("ExampleSerializer04") { example.exampleSerializer04.main() }.verifyOutputLines(
            "PrimitiveDescriptor(kotlin.Int)"
        )
    }

    @Test
    fun testExampleSerializer05() {
        captureOutput("ExampleSerializer05") { example.exampleSerializer05.main() }.verifyOutputLines(
            "kotlin.collections.ArrayList(PrimitiveDescriptor(kotlin.String))"
        )
    }

    @Test
    fun testExampleSerializer06() {
        captureOutput("ExampleSerializer06") { example.exampleSerializer06.main() }.verifyOutputLines(
            "kotlin.collections.LinkedHashMap(PrimitiveDescriptor(kotlin.String), Color(rgb: kotlin.Int))"
        )
    }

    @Test
    fun testExampleSerializer07() {
        captureOutput("ExampleSerializer07") { example.exampleSerializer07.main() }.verifyOutputLines(
            "\"00ff00\""
        )
    }

    @Test
    fun testExampleSerializer08() {
        captureOutput("ExampleSerializer08") { example.exampleSerializer08.main() }.verifyOutputLines(
            "65280"
        )
    }

    @Test
    fun testExampleSerializer09() {
        captureOutput("ExampleSerializer09") { example.exampleSerializer09.main() }.verifyOutputLines(
            "{\"background\":\"ffffff\",\"foreground\":\"000000\"}"
        )
    }

    @Test
    fun testExampleSerializer10() {
        captureOutput("ExampleSerializer10") { example.exampleSerializer10.main() }.verifyOutputLines(
            "[0,255,0]"
        )
    }

    @Test
    fun testExampleSerializer11() {
        captureOutput("ExampleSerializer11") { example.exampleSerializer11.main() }.verifyOutputLines(
            "{\"r\":0,\"g\":255,\"b\":0}"
        )
    }

    @Test
    fun testExampleSerializer12() {
        captureOutput("ExampleSerializer12") { example.exampleSerializer12.main() }.verifyOutputLines(
            "{\"r\":0,\"g\":255,\"b\":0}"
        )
    }

    @Test
    fun testExampleSerializer13() {
        captureOutput("ExampleSerializer13") { example.exampleSerializer13.main() }.verifyOutputLines(
            "{\"r\":0,\"g\":255,\"b\":0}"
        )
    }

    @Test
    fun testExampleSerializer14() {
        captureOutput("ExampleSerializer14") { example.exampleSerializer14.main() }.verifyOutputLines(
            "1455494400000"
        )
    }

    @Test
    fun testExampleSerializer15() {
        captureOutput("ExampleSerializer15") { example.exampleSerializer15.main() }.verifyOutputLines(
            "{\"name\":\"Kotlin\",\"stableReleaseDate\":1455494400000}"
        )
    }

    @Test
    fun testExampleSerializer16() {
        captureOutput("ExampleSerializer16") { example.exampleSerializer16.main() }.verifyOutputLines(
            "{\"name\":\"Kotlin\",\"stableReleaseDate\":1455494400000}"
        )
    }

    @Test
    fun testExampleSerializer17() {
        captureOutput("ExampleSerializer17") { example.exampleSerializer17.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\"}",
            "Box(contents=Project(name=kotlinx.serialization))"
        )
    }

    @Test
    fun testExampleSerializer18() {
        captureOutput("ExampleSerializer18") { example.exampleSerializer18.main() }.verifyOutputLinesStart(
            "Exception in thread \"main\" kotlinx.serialization.SerializationException: Serializer for class 'Date' is not found.",
            "Mark the class as @Serializable or provide the serializer explicitly."
        )
    }

    @Test
    fun testExampleSerializer19() {
        captureOutput("ExampleSerializer19") { example.exampleSerializer19.main() }.verifyOutputLines(
            "{\"name\":\"Kotlin\",\"stableReleaseDate\":1455494400000}"
        )
    }

    @Test
    fun testExampleSerializer20() {
        captureOutput("ExampleSerializer20") { example.exampleSerializer20.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}"
        )
    }

    @Test
    fun testExampleSerializer21() {
        captureOutput("ExampleSerializer21") { example.exampleSerializer21.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"stars\":9000}"
        )
    }
}