1 /* 2 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.serialization.json 6 7 import kotlin.test.* 8 9 class JsonConfigurationTest { 10 11 @Test testPrettyPrintnull12 fun testPrettyPrint() { 13 json(true, "") 14 json(true, "\n") 15 json(true, "\r") 16 json(true, "\t") 17 json(true, " ") 18 json(true, " ") 19 json(true, " \t\r\n\t ") 20 assertFailsWith<IllegalArgumentException> { json(false, " ") } 21 assertFailsWith<IllegalArgumentException> { json(false, " ") } 22 assertFailsWith<IllegalArgumentException> { json(true, "f") } 23 assertFailsWith<IllegalArgumentException> { json(true, "\tf\n") } 24 } 25 <lambda>null26 private fun json(prettyPrint: Boolean, prettyPrintIndent: String) = Json { 27 this.prettyPrint = prettyPrint 28 this.prettyPrintIndent = prettyPrintIndent 29 } 30 } 31