File: quote_test.go

package info (click to toggle)
golang-github-kballard-go-shellquote 0.0~git20180428.95032a8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, experimental, sid, trixie
  • size: 88 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package shellquote

import (
	"testing"
)

func TestSimpleJoin(t *testing.T) {
	for _, elem := range simpleJoinTest {
		output := Join(elem.input...)
		if output != elem.output {
			t.Errorf("Input %q, got %q, expected %q", elem.input, output, elem.output)
		}
	}
}

var simpleJoinTest = []struct {
	input  []string
	output string
}{
	{[]string{"test"}, "test"},
	{[]string{"hello goodbye"}, "'hello goodbye'"},
	{[]string{"hello", "goodbye"}, "hello goodbye"},
	{[]string{"don't you know the dewey decimal system?"}, "'don'\\''t you know the dewey decimal system?'"},
	{[]string{"don't", "you", "know", "the", "dewey", "decimal", "system?"}, "don\\'t you know the dewey decimal system\\?"},
	{[]string{"~user", "u~ser", " ~user", "!~user"}, "\\~user u~ser ' ~user' \\!~user"},
	{[]string{"foo*", "M{ovies,usic}", "ab[cd]", "%3"}, "foo\\* M\\{ovies,usic} ab\\[cd] %3"},
	{[]string{"one", "", "three"}, "one '' three"},
	{[]string{"some(parentheses)"}, "some\\(parentheses\\)"},
	{[]string{"$some_ot~her_)spe!cial_*_characters"}, "\\$some_ot~her_\\)spe\\!cial_\\*_characters"},
	{[]string{"' "}, "\\'' '"},
}