aboutsummaryrefslogtreecommitdiff
path: root/strutil_test.go
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-04-09 18:12:06 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-04-09 18:12:06 +0900
commit248e754456015170241fc4c02aa0e444a6d861a7 (patch)
tree9793df60214027f3cebe8fffb667beb0609ed96e /strutil_test.go
parentcc919ae39aaab456fad2fe89e17abb71d4964747 (diff)
downloadkati-248e754456015170241fc4c02aa0e444a6d861a7.tar.gz
Rewrite spliceSpaces without regexp
30 secs => 18 secs
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",