From cca7a59bba93358e5c4f0f8f44e91a4e722e7cdf Mon Sep 17 00:00:00 2001 From: meztihn Date: Sun, 4 Feb 2018 13:31:32 +0500 Subject: [PATCH] KT-11208 Improve readLine's tests readability --- libraries/stdlib/test/io/Console.kt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/libraries/stdlib/test/io/Console.kt b/libraries/stdlib/test/io/Console.kt index 70b911ba7e2..0a6d91b362b 100644 --- a/libraries/stdlib/test/io/Console.kt +++ b/libraries/stdlib/test/io/Console.kt @@ -21,42 +21,47 @@ import java.nio.charset.Charset import kotlin.test.* class ConsoleTest { - private val defaultLineSeparator: String = "\n" + private val linuxLineSeparator: String = "\n" + private val windowsLineSeparator: String = "\r\n" @Test fun shouldReadEmptyLine() { - testReadLine("") + testReadLine("", emptyList()) } @Test fun shouldReadOneLetter() { - testReadLine("a", "a") + testReadLine("a", listOf("a")) } @Test fun shouldReadOneLine() { - testReadLine("first", "first") + testReadLine("first", listOf("first")) } @Test fun shouldReadTwoLines() { - testReadLine("first${defaultLineSeparator}second", "first", "second") + testReadLine("first${linuxLineSeparator}second", listOf("first", "second")) + } + + @Test + fun shouldReadConsecutiveEmptyLines() { + testReadLine("$linuxLineSeparator$linuxLineSeparator", listOf("", "")) } @Test fun shouldReadWindowsLineSeparator() { - val lineSeparator = "\r\n" - testReadLine("first${lineSeparator}second", "first", "second") + testReadLine("first${windowsLineSeparator}second", listOf("first", "second")) } @Test fun shouldReadMultibyteEncodings() { - testReadLine("first${defaultLineSeparator}second", "first", "second", charset = Charsets.UTF_32) + testReadLine("first${linuxLineSeparator}second", listOf("first", "second"), charset = Charsets.UTF_32) } - private fun testReadLine(text: String, vararg expected: String, charset: Charset = Charsets.UTF_8) { + private fun testReadLine(text: String, expected: List, charset: Charset = Charsets.UTF_8) { val actual = readLines(text, charset) - assertEquals(expected.asList(), actual) + assertEquals(expected, actual) } private fun readLines(text: String, charset: Charset): List {