aboutsummaryrefslogtreecommitdiff
path: root/strutil_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'strutil_test.go')
-rw-r--r--strutil_test.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/strutil_test.go b/strutil_test.go
index fdcdcd5..0bf7174 100644
--- a/strutil_test.go
+++ b/strutil_test.go
@@ -1,16 +1,50 @@
package main
import (
+ "reflect"
"testing"
)
+func TestSplitSpaces(t *testing.T) {
+ for _, tc := range []struct {
+ in string
+ want []string
+ }{
+ {
+ in: "foo",
+ want: []string{"foo"},
+ },
+ {
+ in: " ",
+ want: nil,
+ },
+ {
+ in: " foo bar ",
+ want: []string{"foo", "bar"},
+ },
+ {
+ in: " foo bar",
+ want: []string{"foo", "bar"},
+ },
+ {
+ in: "foo bar ",
+ want: []string{"foo", "bar"},
+ },
+ } {
+ got := splitSpaces(tc.in)
+ if !reflect.DeepEqual(got, tc.want) {
+ t.Errorf(`splitSpaces(%q)=%q, want %q`, tc.in, got, tc.want)
+ }
+ }
+}
+
func TestSubstPattern(t *testing.T) {
for _, tc := range []struct {
pat string
repl string
in string
want string
- } {
+ }{
{
pat: "%.c",
repl: "%.o",