[skip ci] add test escaping raw String
This commit is contained in:
parent
5fef5add99
commit
fc625a8124
1 changed files with 22 additions and 2 deletions
|
@ -10,15 +10,35 @@ internal class UtilsKtTest {
|
||||||
|
|
||||||
@ContainerTest
|
@ContainerTest
|
||||||
@Test
|
@Test
|
||||||
fun printToShell_escapes_successfully() {
|
fun printToShell_escapes_String_successfully() {
|
||||||
// given
|
// given
|
||||||
val a = Prov.defaultInstance()
|
val a = Prov.defaultInstance()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val testString = "test if newline \n and apostrophe's ' \" and special chars !§$%[]\\ äöüß \$variable are handled correctly"
|
val testString = "test if newline \n and apostrophe's ' \" and special chars $ !§$%[]\\ äöüß \$variable and tabs \t are handled correctly"
|
||||||
|
|
||||||
val res = a.cmd(echoCommandForText(testString)).out
|
val res = a.cmd(echoCommandForText(testString)).out
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(testString, res)
|
assertEquals(testString, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ContainerTest
|
||||||
|
@Test
|
||||||
|
fun printToShell_escapes_raw_String_successfully() {
|
||||||
|
// given
|
||||||
|
val a = Prov.defaultInstance()
|
||||||
|
|
||||||
|
// when
|
||||||
|
val testMultiLineString = """
|
||||||
|
test if newlines
|
||||||
|
\n
|
||||||
|
and apostrophe's ' " \" \' and special chars $ {} $\{something}!§$%[]\\ äöüß $\notakotlinvariable ${'$'}notakotlinvariable and tabs \t are handled correctly
|
||||||
|
"""
|
||||||
|
|
||||||
|
val resMl = a.cmd(echoCommandForText(testMultiLineString)).out
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertEquals(testMultiLineString, resMl)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue