Skip to content

Commit d25c5ef

Browse files
authored
Merge pull request mattn#35 from markus-oberhumer/minor-testcase-cleanups
Minor testcase cleanups
2 parents 15c6c4b + f722472 commit d25c5ef

File tree

1 file changed

+7
-40
lines changed

1 file changed

+7
-40
lines changed

shellwords_test.go

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ var testcases = []struct {
1212
line string
1313
expected []string
1414
}{
15+
{``, []string{}},
16+
{`""`, []string{``}},
17+
{`''`, []string{``}},
1518
{`var --bar=baz`, []string{`var`, `--bar=baz`}},
1619
{`var --bar="baz"`, []string{`var`, `--bar=baz`}},
1720
{`var "--bar=baz"`, []string{`var`, `--bar=baz`}},
@@ -25,10 +28,12 @@ var testcases = []struct {
2528
{`var --"bar baz"`, []string{`var`, `--bar baz`}},
2629
{`a "b"`, []string{`a`, `b`}},
2730
{`a " b "`, []string{`a`, ` b `}},
28-
{`a " "`, []string{`a`, ` `}}, // FAILS !
31+
{`a " "`, []string{`a`, ` `}},
2932
{`a 'b'`, []string{`a`, `b`}},
3033
{`a ' b '`, []string{`a`, ` b `}},
31-
{`a ' '`, []string{`a`, ` `}}, // FAILS !
34+
{`a ' '`, []string{`a`, ` `}},
35+
{"foo bar\\ ", []string{`foo`, `bar `}},
36+
{`foo "" bar ''`, []string{`foo`, ``, `bar`, ``}},
3237
}
3338

3439
func TestSimple(t *testing.T) {
@@ -59,44 +64,6 @@ func TestError(t *testing.T) {
5964
}
6065
}
6166

62-
func TestLastSpace(t *testing.T) {
63-
args, err := Parse("foo bar\\ ")
64-
if err != nil {
65-
t.Fatal(err)
66-
}
67-
if len(args) != 2 {
68-
t.Fatal("Should have two elements")
69-
}
70-
if args[0] != "foo" {
71-
t.Fatal("1st element should be `foo`")
72-
}
73-
if args[1] != "bar " {
74-
t.Fatal("1st element should be `bar `")
75-
}
76-
}
77-
78-
func TestEmptyArgs(t *testing.T) {
79-
args, err := Parse(`foo "" bar ''`)
80-
if err != nil {
81-
t.Fatal(err)
82-
}
83-
if len(args) != 4 {
84-
t.Fatal("Should have three elements")
85-
}
86-
if args[0] != "foo" {
87-
t.Fatal("1st element should be `foo`")
88-
}
89-
if args[1] != "" {
90-
t.Fatal("2nd element should be empty")
91-
}
92-
if args[2] != "bar" {
93-
t.Fatal("3rd element should be `bar`")
94-
}
95-
if args[3] != "" {
96-
t.Fatal("4th element should be empty")
97-
}
98-
}
99-
10067
func TestShellRun(t *testing.T) {
10168
dir, err := os.Getwd()
10269
if err != nil {

0 commit comments

Comments
 (0)