summaryrefslogtreecommitdiff
path: root/guide/test/JsonTest.kt
blob: c92f57bf610b51ca39a8f09a6de91904baf46921 (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
157
158
159
160
161
162
163
// This file was automatically generated from json.md by Knit tool. Do not edit.
package example.test

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

class JsonTest {
    @Test
    fun testExampleJson01() {
        captureOutput("ExampleJson01") { example.exampleJson01.main() }.verifyOutputLines(
            "{",
            "    \"name\": \"kotlinx.serialization\",",
            "    \"language\": \"Kotlin\"",
            "}"
        )
    }

    @Test
    fun testExampleJson02() {
        captureOutput("ExampleJson02") { example.exampleJson02.main() }.verifyOutputLines(
            "Project(name=kotlinx.serialization, status=SUPPORTED, votes=9000)"
        )
    }

    @Test
    fun testExampleJson03() {
        captureOutput("ExampleJson03") { example.exampleJson03.main() }.verifyOutputLines(
            "Project(name=kotlinx.serialization)"
        )
    }

    @Test
    fun testExampleJson04() {
        captureOutput("ExampleJson04") { example.exampleJson04.main() }.verifyOutputLines(
            "Project(name=kotlinx.serialization)",
            "Project(name=kotlinx.coroutines)"
        )
    }

    @Test
    fun testExampleJson05() {
        captureOutput("ExampleJson05") { example.exampleJson05.main() }.verifyOutputLines(
            "Project(name=kotlinx.serialization, language=Kotlin)"
        )
    }

    @Test
    fun testExampleJson06() {
        captureOutput("ExampleJson06") { example.exampleJson06.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\",\"website\":null}"
        )
    }

    @Test
    fun testExampleJson07() {
        captureOutput("ExampleJson07") { example.exampleJson07.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}",
            "Project(name=kotlinx.serialization, language=Kotlin, version=1.2.2, website=null, description=null)"
        )
    }

    @Test
    fun testExampleJson08() {
        captureOutput("ExampleJson08") { example.exampleJson08.main() }.verifyOutputLines(
            "[{\"name\":\"kotlinx.serialization\"},\"Serialization\",{\"name\":\"kotlinx.coroutines\"},\"Coroutines\"]"
        )
    }

    @Test
    fun testExampleJson09() {
        captureOutput("ExampleJson09") { example.exampleJson09.main() }.verifyOutputLines(
            "{\"value\":NaN}"
        )
    }

    @Test
    fun testExampleJson10() {
        captureOutput("ExampleJson10") { example.exampleJson10.main() }.verifyOutputLines(
            "{\"#class\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}"
        )
    }

    @Test
    fun testExampleJson11() {
        captureOutput("ExampleJson11") { example.exampleJson11.main() }.verifyOutputLines(
            "{\"message\":{\"message_type\":\"my.app.BaseMessage\",\"message\":\"not found\"},\"error\":{\"message_type\":\"my.app.GenericError\",\"error_code\":404}}"
        )
    }

    @Test
    fun testExampleJson12() {
        captureOutput("ExampleJson12") { example.exampleJson12.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}"
        )
    }

    @Test
    fun testExampleJson13() {
        captureOutput("ExampleJson13") { example.exampleJson13.main() }.verifyOutputLines(
            "9042"
        )
    }

    @Test
    fun testExampleJson14() {
        captureOutput("ExampleJson14") { example.exampleJson14.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"owner\":{\"name\":\"kotlin\"},\"forks\":[{\"votes\":42},{\"votes\":9000}]}"
        )
    }

    @Test
    fun testExampleJson15() {
        captureOutput("ExampleJson15") { example.exampleJson15.main() }.verifyOutputLines(
            "Project(name=kotlinx.serialization, language=Kotlin)"
        )
    }

    @Test
    fun testExampleJson16() {
        captureOutput("ExampleJson16") { example.exampleJson16.main() }.verifyOutputLines(
            "Project(name=kotlinx.serialization, users=[User(name=kotlin)])",
            "Project(name=kotlinx.serialization, users=[User(name=kotlin), User(name=jetbrains)])"
        )
    }

    @Test
    fun testExampleJson17() {
        captureOutput("ExampleJson17") { example.exampleJson17.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"users\":{\"name\":\"kotlin\"}}"
        )
    }

    @Test
    fun testExampleJson18() {
        captureOutput("ExampleJson18") { example.exampleJson18.main() }.verifyOutputLines(
            "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}",
            "{\"name\":\"kotlinx.serialization\"}"
        )
    }

    @Test
    fun testExampleJson19() {
        captureOutput("ExampleJson19") { example.exampleJson19.main() }.verifyOutputLines(
            "[{\"name\":\"kotlinx.serialization\",\"owner\":\"kotlin\"},{\"name\":\"example\"}]",
            "[OwnedProject(name=kotlinx.serialization, owner=kotlin), BasicProject(name=example)]"
        )
    }

    @Test
    fun testExampleJson20() {
        captureOutput("ExampleJson20") { example.exampleJson20.main() }.verifyOutputLines(
            "[{\"name\":\"kotlinx.serialization\"},{\"error\":\"Not found\"}]",
            "[Ok(data=Project(name=kotlinx.serialization)), Error(message=Not found)]"
        )
    }

    @Test
    fun testExampleJson21() {
        captureOutput("ExampleJson21") { example.exampleJson21.main() }.verifyOutputLines(
            "UnknownProject(name=example, details={\"type\":\"unknown\",\"maintainer\":\"Unknown\",\"license\":\"Apache 2.0\"})"
        )
    }
}