github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/post-processor/atlas/util_test.go (about) 1 package atlas 2 3 import ( 4 "testing" 5 ) 6 7 func TestLongestCommonPrefix(t *testing.T) { 8 cases := []struct { 9 Input []string 10 Output string 11 }{ 12 { 13 []string{"foo", "bar"}, 14 "", 15 }, 16 { 17 []string{"foo", "foobar"}, 18 "", 19 }, 20 { 21 []string{"foo/", "foo/bar"}, 22 "foo/", 23 }, 24 { 25 []string{"/foo/", "/bar"}, 26 "/", 27 }, 28 } 29 30 for _, tc := range cases { 31 actual := longestCommonPrefix(tc.Input) 32 if actual != tc.Output { 33 t.Fatalf("bad: %#v\n\n%#v", actual, tc.Input) 34 } 35 } 36 }