Skip to content

Commit

Permalink
Remove \r from each line
Browse files Browse the repository at this point in the history
  • Loading branch information
jonolehagemo committed Sep 27, 2023
1 parent cde60c5 commit 6bbcbe8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data class KotlinArguments(
}

fun getInputContentAsStringList(delimiter: String = DEFAULT_LINEBREAK_CHAR): List<String> =
inputFileContent.split(delimiter)
inputFileContent.split(delimiter).map { it.trim('\r') }

fun getInputContentAsInputStream(): InputStream = inputFileContent.byteInputStream(Charsets.ISO_8859_1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,29 @@ class KotlinArgumentsTest : BehaviorSpec({
}
}
}

Given("KotlinArguments#getInputContentAsStringList()") {

forAll(
row("empty content", "", listOf("")),
row("content with new line", "a\nb", listOf("a", "b")),
row("content with carriage return and new line", "a\r\nb", listOf("a", "b")),
row("content with carriage return and new line plus blank line at end", "a\r\nb\n", listOf("a", "b", "")),
) { description, content, expectedList ->
When(description) {
val kotlinArguments = KotlinArguments(
skjema = "15",
aargang = Year.now().value.toString(),
region = "030100",
inputFileContent = content
)

val contentAsStringList = kotlinArguments.getInputContentAsStringList()

Then("getInputContentAsStringList() should produce the expectedList") {
contentAsStringList shouldBe expectedList
}
}
}
}
})

0 comments on commit 6bbcbe8

Please sign in to comment.