1 // This file was automatically generated from json.md by Knit tool. Do not edit. 2 package example.test 3 4 import org.junit.Test 5 import kotlinx.knit.test.* 6 7 class JsonTest { 8 @Test testExampleJson01null9 fun testExampleJson01() { 10 captureOutput("ExampleJson01") { example.exampleJson01.main() }.verifyOutputLines( 11 "{", 12 " \"name\": \"kotlinx.serialization\",", 13 " \"language\": \"Kotlin\"", 14 "}" 15 ) 16 } 17 18 @Test testExampleJson02null19 fun testExampleJson02() { 20 captureOutput("ExampleJson02") { example.exampleJson02.main() }.verifyOutputLines( 21 "Project(name=kotlinx.serialization, status=SUPPORTED, votes=9000)" 22 ) 23 } 24 25 @Test testExampleJson03null26 fun testExampleJson03() { 27 captureOutput("ExampleJson03") { example.exampleJson03.main() }.verifyOutputLines( 28 "Project(name=kotlinx.serialization)" 29 ) 30 } 31 32 @Test testExampleJson04null33 fun testExampleJson04() { 34 captureOutput("ExampleJson04") { example.exampleJson04.main() }.verifyOutputLines( 35 "Project(name=kotlinx.serialization)", 36 "Project(name=kotlinx.coroutines)" 37 ) 38 } 39 40 @Test testExampleJson05null41 fun testExampleJson05() { 42 captureOutput("ExampleJson05") { example.exampleJson05.main() }.verifyOutputLines( 43 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\",\"website\":null}" 44 ) 45 } 46 47 @Test testExampleJson06null48 fun testExampleJson06() { 49 captureOutput("ExampleJson06") { example.exampleJson06.main() }.verifyOutputLines( 50 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}", 51 "Project(name=kotlinx.serialization, language=Kotlin, version=1.2.2, website=null, description=null)" 52 ) 53 } 54 55 @Test testExampleJson07null56 fun testExampleJson07() { 57 captureOutput("ExampleJson07") { example.exampleJson07.main() }.verifyOutputLines( 58 "Project(name=kotlinx.serialization, language=Kotlin)" 59 ) 60 } 61 62 @Test testExampleJson08null63 fun testExampleJson08() { 64 captureOutput("ExampleJson08") { example.exampleJson08.main() }.verifyOutputLines( 65 "Brush(foreground=BLACK, background=null)" 66 ) 67 } 68 69 @Test testExampleJson09null70 fun testExampleJson09() { 71 captureOutput("ExampleJson09") { example.exampleJson09.main() }.verifyOutputLines( 72 "[{\"name\":\"kotlinx.serialization\"},\"Serialization\",{\"name\":\"kotlinx.coroutines\"},\"Coroutines\"]" 73 ) 74 } 75 76 @Test testExampleJson10null77 fun testExampleJson10() { 78 captureOutput("ExampleJson10") { example.exampleJson10.main() }.verifyOutputLines( 79 "{\"value\":NaN}" 80 ) 81 } 82 83 @Test testExampleJson11null84 fun testExampleJson11() { 85 captureOutput("ExampleJson11") { example.exampleJson11.main() }.verifyOutputLines( 86 "{\"#class\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 87 ) 88 } 89 90 @Test testExampleJson12null91 fun testExampleJson12() { 92 captureOutput("ExampleJson12") { example.exampleJson12.main() }.verifyOutputLines( 93 "{\"message\":{\"message_type\":\"my.app.BaseMessage\",\"message\":\"not found\"},\"error\":{\"message_type\":\"my.app.GenericError\",\"error_code\":404}}" 94 ) 95 } 96 97 @Test testExampleJson13null98 fun testExampleJson13() { 99 captureOutput("ExampleJson13") { example.exampleJson13.main() }.verifyOutputLines( 100 "{\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 101 ) 102 } 103 104 @Test testExampleJson14null105 fun testExampleJson14() { 106 captureOutput("ExampleJson14") { example.exampleJson14.main() }.verifyOutputLines( 107 "CasesList(cases=[VALUE_A, VALUE_B])" 108 ) 109 } 110 111 @Test testExampleJson15null112 fun testExampleJson15() { 113 captureOutput("ExampleJson15") { example.exampleJson15.main() }.verifyOutputLines( 114 "{\"project_name\":\"kotlinx.serialization\",\"project_owner\":\"Kotlin\"}" 115 ) 116 } 117 118 @Test testExampleJson16null119 fun testExampleJson16() { 120 captureOutput("ExampleJson16") { example.exampleJson16.main() }.verifyOutputLines( 121 "{\"base64Input\":\"Zm9vIHN0cmluZw==\"}", 122 "foo string" 123 ) 124 } 125 126 @Test testExampleJson17null127 fun testExampleJson17() { 128 captureOutput("ExampleJson17") { example.exampleJson17.main() }.verifyOutputLines( 129 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}" 130 ) 131 } 132 133 @Test testExampleJson18null134 fun testExampleJson18() { 135 captureOutput("ExampleJson18") { example.exampleJson18.main() }.verifyOutputLines( 136 "9042" 137 ) 138 } 139 140 @Test testExampleJson19null141 fun testExampleJson19() { 142 captureOutput("ExampleJson19") { example.exampleJson19.main() }.verifyOutputLines( 143 "{\"name\":\"kotlinx.serialization\",\"owner\":{\"name\":\"kotlin\"},\"forks\":[{\"votes\":42},{\"votes\":9000}]}" 144 ) 145 } 146 147 @Test testExampleJson20null148 fun testExampleJson20() { 149 captureOutput("ExampleJson20") { example.exampleJson20.main() }.verifyOutputLines( 150 "Project(name=kotlinx.serialization, language=Kotlin)" 151 ) 152 } 153 154 @Test testExampleJson21null155 fun testExampleJson21() { 156 captureOutput("ExampleJson21") { example.exampleJson21.main() }.verifyOutputLines( 157 "{", 158 " \"pi_double\": 3.141592653589793,", 159 " \"pi_string\": \"3.141592653589793238462643383279\"", 160 "}" 161 ) 162 } 163 164 @Test testExampleJson22null165 fun testExampleJson22() { 166 captureOutput("ExampleJson22") { example.exampleJson22.main() }.verifyOutputLines( 167 "{", 168 " \"pi_literal\": 3.141592653589793238462643383279,", 169 " \"pi_double\": 3.141592653589793,", 170 " \"pi_string\": \"3.141592653589793238462643383279\"", 171 "}" 172 ) 173 } 174 175 @Test testExampleJson23null176 fun testExampleJson23() { 177 captureOutput("ExampleJson23") { example.exampleJson23.main() }.verifyOutputLines( 178 "3.141592653589793238462643383279" 179 ) 180 } 181 182 @Test testExampleJson24null183 fun testExampleJson24() { 184 captureOutput("ExampleJson24") { example.exampleJson24.main() }.verifyOutputLinesStart( 185 "Exception in thread \"main\" kotlinx.serialization.json.internal.JsonEncodingException: Creating a literal unquoted value of 'null' is forbidden. If you want to create JSON null literal, use JsonNull object, otherwise, use JsonPrimitive" 186 ) 187 } 188 189 @Test testExampleJson25null190 fun testExampleJson25() { 191 captureOutput("ExampleJson25") { example.exampleJson25.main() }.verifyOutputLines( 192 "Project(name=kotlinx.serialization, users=[User(name=kotlin)])", 193 "Project(name=kotlinx.serialization, users=[User(name=kotlin), User(name=jetbrains)])" 194 ) 195 } 196 197 @Test testExampleJson26null198 fun testExampleJson26() { 199 captureOutput("ExampleJson26") { example.exampleJson26.main() }.verifyOutputLines( 200 "{\"name\":\"kotlinx.serialization\",\"users\":{\"name\":\"kotlin\"}}" 201 ) 202 } 203 204 @Test testExampleJson27null205 fun testExampleJson27() { 206 captureOutput("ExampleJson27") { example.exampleJson27.main() }.verifyOutputLines( 207 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}", 208 "{\"name\":\"kotlinx.serialization\"}" 209 ) 210 } 211 212 @Test testExampleJson28null213 fun testExampleJson28() { 214 captureOutput("ExampleJson28") { example.exampleJson28.main() }.verifyOutputLines( 215 "[{\"name\":\"kotlinx.serialization\",\"owner\":\"kotlin\"},{\"name\":\"example\"}]", 216 "[OwnedProject(name=kotlinx.serialization, owner=kotlin), BasicProject(name=example)]" 217 ) 218 } 219 220 @Test testExampleJson29null221 fun testExampleJson29() { 222 captureOutput("ExampleJson29") { example.exampleJson29.main() }.verifyOutputLines( 223 "BasicProject(name=example)" 224 ) 225 } 226 227 @Test testExampleJson30null228 fun testExampleJson30() { 229 captureOutput("ExampleJson30") { example.exampleJson30.main() }.verifyOutputLines( 230 "[{\"name\":\"kotlinx.serialization\"},{\"error\":\"Not found\"}]", 231 "[Ok(data=Project(name=kotlinx.serialization)), Error(message=Not found)]" 232 ) 233 } 234 235 @Test testExampleJson31null236 fun testExampleJson31() { 237 captureOutput("ExampleJson31") { example.exampleJson31.main() }.verifyOutputLines( 238 "UnknownProject(name=example, details={\"type\":\"unknown\",\"maintainer\":\"Unknown\",\"license\":\"Apache 2.0\"})" 239 ) 240 } 241 } 242