Files
shell/main_test.go
2023-11-06 21:15:17 +01:00

27 lines
614 B
Go

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)
}
})
}
}