github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2015/tricks/string_test.go (about) 1 // +build ignore 2 3 package strings_test 4 5 import ( 6 "strings" 7 "testing" 8 ) 9 10 func TestIndex(t *testing.T) { 11 var tests = []struct { 12 s string 13 sep string 14 out int 15 }{ 16 {"", "", 0}, 17 {"", "a", -1}, 18 {"fo", "foo", -1}, 19 {"foo", "foo", 0}, 20 {"oofofoofooo", "f", 2}, 21 // etc 22 } 23 for _, test := range tests { 24 actual := strings.Index(test.s, test.sep) 25 if actual != test.out { 26 t.Errorf("Index(%q,%q) = %v; want %v", test.s, test.sep, actual, test.out) 27 } 28 } 29 }