aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/peterh/liner/prefix_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/peterh/liner/prefix_test.go')
-rw-r--r--Godeps/_workspace/src/github.com/peterh/liner/prefix_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/peterh/liner/prefix_test.go b/Godeps/_workspace/src/github.com/peterh/liner/prefix_test.go
new file mode 100644
index 000000000..c826d6c3b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/peterh/liner/prefix_test.go
@@ -0,0 +1,37 @@
+// +build windows linux darwin openbsd freebsd netbsd
+
+package liner
+
+import "testing"
+
+type testItem struct {
+ list []string
+ prefix string
+}
+
+func TestPrefix(t *testing.T) {
+ list := []testItem{
+ {[]string{"food", "foot"}, "foo"},
+ {[]string{"foo", "foot"}, "foo"},
+ {[]string{"food", "foo"}, "foo"},
+ {[]string{"food", "foe", "foot"}, "fo"},
+ {[]string{"food", "foot", "barbeque"}, ""},
+ {[]string{"cafeteria", "café"}, "caf"},
+ {[]string{"cafe", "café"}, "caf"},
+ {[]string{"cafè", "café"}, "caf"},
+ {[]string{"cafés", "café"}, "café"},
+ {[]string{"áéíóú", "áéíóú"}, "áéíóú"},
+ {[]string{"éclairs", "éclairs"}, "éclairs"},
+ {[]string{"éclairs are the best", "éclairs are great", "éclairs"}, "éclairs"},
+ {[]string{"éclair", "éclairs"}, "éclair"},
+ {[]string{"éclairs", "éclair"}, "éclair"},
+ {[]string{"éclair", "élan"}, "é"},
+ }
+
+ for _, test := range list {
+ lcp := longestCommonPrefix(test.list)
+ if lcp != test.prefix {
+ t.Errorf("%s != %s for %+v", lcp, test.prefix, test.list)
+ }
+ }
+}