27 lines
614 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|