Skip to content

Commit 56317c8

Browse files
authored
Merge pull request #114 from carapace-sh/add-tests
join: added tests
2 parents d1b3eb4 + 7ab7c40 commit 56317c8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

shlex_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,20 @@ func TestJoin(t *testing.T) {
121121
for expected, words := range map[string][]string{
122122
``: {},
123123
`echo "\$(ls)"`: {"echo", "$(ls)"},
124-
"echo \"\\`ls\\`\"": {"echo", "`ls`"},
125124
"echo \"'ls'\"": {"echo", "'ls'"},
126125
`echo "\"ls\""`: {"echo", `"ls"`},
127126
`echo "\$(ls /tmp)"`: {"echo", "$(ls /tmp)"},
127+
"echo \"\\`ls\\`\"": {"echo", "`ls`"},
128128
`ls /tmp | xargs -n 1 echo`: {"ls", "/tmp", "|", "xargs", "-n", "1", "echo"},
129-
`echo "one\ntwo"`: {"echo", "one\ntwo"},
129+
130+
`echo "with\"doubleQuote"`: {"echo", "with\"doubleQuote"},
131+
`echo "with'singleQuote"`: {"echo", "with'singleQuote"},
132+
`echo "with space"`: {"echo", "with space"},
133+
"echo \"with\\`backtick\"": {"echo", "with`backtick"},
134+
`echo "with\$dollar"`: {"echo", "with$dollar"},
135+
`echo "with\nlinefeed"`: {"echo", "with\nlinefeed"},
136+
`echo "with\rcarriageReturn"`: {"echo", "with\rcarriageReturn"},
137+
`echo "with\ttab"`: {"echo", "with\ttab"},
130138
} {
131139
if actual := Join(words); actual != expected {
132140
t.Errorf("joined words don't match\nactual : %#v\nexpected: %#v", actual, expected)

0 commit comments

Comments
 (0)