summaryrefslogtreecommitdiff
path: root/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonConfigurationTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonConfigurationTest.kt')
-rw-r--r--formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonConfigurationTest.kt30
1 files changed, 30 insertions, 0 deletions
diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonConfigurationTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonConfigurationTest.kt
new file mode 100644
index 00000000..2a4dc2c1
--- /dev/null
+++ b/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonConfigurationTest.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.serialization.json
+
+import kotlin.test.*
+
+class JsonConfigurationTest {
+
+ @Test
+ fun testPrettyPrint() {
+ json(true, "")
+ json(true, "\n")
+ json(true, "\r")
+ json(true, "\t")
+ json(true, " ")
+ json(true, " ")
+ json(true, " \t\r\n\t ")
+ assertFailsWith<IllegalArgumentException> { json(false, " ") }
+ assertFailsWith<IllegalArgumentException> { json(false, " ") }
+ assertFailsWith<IllegalArgumentException> { json(true, "f") }
+ assertFailsWith<IllegalArgumentException> { json(true, "\tf\n") }
+ }
+
+ private fun json(prettyPrint: Boolean, prettyPrintIndent: String) = Json {
+ this.prettyPrint = prettyPrint
+ this.prettyPrintIndent = prettyPrintIndent
+ }
+}