run cmds in shell, cd & exit builtins
This commit is contained in:
26
main_test.go
Normal file
26
main_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplitLine(t *testing.T) {
|
||||
tests := []struct {
|
||||
line string
|
||||
want []string
|
||||
}{
|
||||
{"", []string{}},
|
||||
{"arg1 arg2 arg3", []string{"arg1", "arg2", "arg3"}},
|
||||
{" arg1\targ2\narg3\rarg4\aarg5 ", []string{"arg1", "arg2", "arg3", "arg4", "arg5"}},
|
||||
{"\"quoted arg\" 'another arg'", []string{"\"quoted", "arg\"", "'another", "arg'"}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.line, func(t *testing.T) {
|
||||
if got := split_line(tt.line); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("split_line(%q) = %v, want %v", tt.line, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user