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 "Project(name=kotlinx.serialization, language=Kotlin)" 44 ) 45 } 46 47 @Test testExampleJson06null48 fun testExampleJson06() { 49 captureOutput("ExampleJson06") { example.exampleJson06.main() }.verifyOutputLines( 50 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\",\"website\":null}" 51 ) 52 } 53 54 @Test testExampleJson07null55 fun testExampleJson07() { 56 captureOutput("ExampleJson07") { example.exampleJson07.main() }.verifyOutputLines( 57 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}", 58 "Project(name=kotlinx.serialization, language=Kotlin, version=1.2.2, website=null, description=null)" 59 ) 60 } 61 62 @Test testExampleJson08null63 fun testExampleJson08() { 64 captureOutput("ExampleJson08") { example.exampleJson08.main() }.verifyOutputLines( 65 "[{\"name\":\"kotlinx.serialization\"},\"Serialization\",{\"name\":\"kotlinx.coroutines\"},\"Coroutines\"]" 66 ) 67 } 68 69 @Test testExampleJson09null70 fun testExampleJson09() { 71 captureOutput("ExampleJson09") { example.exampleJson09.main() }.verifyOutputLines( 72 "{\"value\":NaN}" 73 ) 74 } 75 76 @Test testExampleJson10null77 fun testExampleJson10() { 78 captureOutput("ExampleJson10") { example.exampleJson10.main() }.verifyOutputLines( 79 "{\"#class\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 80 ) 81 } 82 83 @Test testExampleJson11null84 fun testExampleJson11() { 85 captureOutput("ExampleJson11") { example.exampleJson11.main() }.verifyOutputLines( 86 "{\"message\":{\"message_type\":\"my.app.BaseMessage\",\"message\":\"not found\"},\"error\":{\"message_type\":\"my.app.GenericError\",\"error_code\":404}}" 87 ) 88 } 89 90 @Test testExampleJson12null91 fun testExampleJson12() { 92 captureOutput("ExampleJson12") { example.exampleJson12.main() }.verifyOutputLines( 93 "{\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 94 ) 95 } 96 97 @Test testExampleJson13null98 fun testExampleJson13() { 99 captureOutput("ExampleJson13") { example.exampleJson13.main() }.verifyOutputLines( 100 "CasesList(cases=[VALUE_A, VALUE_B])" 101 ) 102 } 103 104 @Test testExampleJson14null105 fun testExampleJson14() { 106 captureOutput("ExampleJson14") { example.exampleJson14.main() }.verifyOutputLines( 107 "{\"project_name\":\"kotlinx.serialization\",\"project_owner\":\"Kotlin\"}" 108 ) 109 } 110 111 @Test testExampleJson15null112 fun testExampleJson15() { 113 captureOutput("ExampleJson15") { example.exampleJson15.main() }.verifyOutputLines( 114 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}" 115 ) 116 } 117 118 @Test testExampleJson16null119 fun testExampleJson16() { 120 captureOutput("ExampleJson16") { example.exampleJson16.main() }.verifyOutputLines( 121 "9042" 122 ) 123 } 124 125 @Test testExampleJson17null126 fun testExampleJson17() { 127 captureOutput("ExampleJson17") { example.exampleJson17.main() }.verifyOutputLines( 128 "{\"name\":\"kotlinx.serialization\",\"owner\":{\"name\":\"kotlin\"},\"forks\":[{\"votes\":42},{\"votes\":9000}]}" 129 ) 130 } 131 132 @Test testExampleJson18null133 fun testExampleJson18() { 134 captureOutput("ExampleJson18") { example.exampleJson18.main() }.verifyOutputLines( 135 "Project(name=kotlinx.serialization, language=Kotlin)" 136 ) 137 } 138 139 @Test testExampleJson19null140 fun testExampleJson19() { 141 captureOutput("ExampleJson19") { example.exampleJson19.main() }.verifyOutputLines( 142 "{", 143 " \"pi_double\": 3.141592653589793,", 144 " \"pi_string\": \"3.141592653589793238462643383279\"", 145 "}" 146 ) 147 } 148 149 @Test testExampleJson20null150 fun testExampleJson20() { 151 captureOutput("ExampleJson20") { example.exampleJson20.main() }.verifyOutputLines( 152 "{", 153 " \"pi_literal\": 3.141592653589793238462643383279,", 154 " \"pi_double\": 3.141592653589793,", 155 " \"pi_string\": \"3.141592653589793238462643383279\"", 156 "}" 157 ) 158 } 159 160 @Test testExampleJson21null161 fun testExampleJson21() { 162 captureOutput("ExampleJson21") { example.exampleJson21.main() }.verifyOutputLines( 163 "3.141592653589793238462643383279" 164 ) 165 } 166 167 @Test testExampleJson22null168 fun testExampleJson22() { 169 captureOutput("ExampleJson22") { example.exampleJson22.main() }.verifyOutputLinesStart( 170 "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" 171 ) 172 } 173 174 @Test testExampleJson23null175 fun testExampleJson23() { 176 captureOutput("ExampleJson23") { example.exampleJson23.main() }.verifyOutputLines( 177 "Project(name=kotlinx.serialization, users=[User(name=kotlin)])", 178 "Project(name=kotlinx.serialization, users=[User(name=kotlin), User(name=jetbrains)])" 179 ) 180 } 181 182 @Test testExampleJson24null183 fun testExampleJson24() { 184 captureOutput("ExampleJson24") { example.exampleJson24.main() }.verifyOutputLines( 185 "{\"name\":\"kotlinx.serialization\",\"users\":{\"name\":\"kotlin\"}}" 186 ) 187 } 188 189 @Test testExampleJson25null190 fun testExampleJson25() { 191 captureOutput("ExampleJson25") { example.exampleJson25.main() }.verifyOutputLines( 192 "{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}", 193 "{\"name\":\"kotlinx.serialization\"}" 194 ) 195 } 196 197 @Test testExampleJson26null198 fun testExampleJson26() { 199 captureOutput("ExampleJson26") { example.exampleJson26.main() }.verifyOutputLines( 200 "[{\"name\":\"kotlinx.serialization\",\"owner\":\"kotlin\"},{\"name\":\"example\"}]", 201 "[OwnedProject(name=kotlinx.serialization, owner=kotlin), BasicProject(name=example)]" 202 ) 203 } 204 205 @Test testExampleJson27null206 fun testExampleJson27() { 207 captureOutput("ExampleJson27") { example.exampleJson27.main() }.verifyOutputLines( 208 "[{\"name\":\"kotlinx.serialization\"},{\"error\":\"Not found\"}]", 209 "[Ok(data=Project(name=kotlinx.serialization)), Error(message=Not found)]" 210 ) 211 } 212 213 @Test testExampleJson28null214 fun testExampleJson28() { 215 captureOutput("ExampleJson28") { example.exampleJson28.main() }.verifyOutputLines( 216 "UnknownProject(name=example, details={\"type\":\"unknown\",\"maintainer\":\"Unknown\",\"license\":\"Apache 2.0\"})" 217 ) 218 } 219 } 220