diff options
Diffstat (limited to 'skate')
-rw-r--r-- | skate/url_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/skate/url_test.go b/skate/url_test.go index 8103246..caf05a4 100644 --- a/skate/url_test.go +++ b/skate/url_test.go @@ -148,6 +148,27 @@ func TestSanitizeURL(t *testing.T) { } } +func TestHasAnyPrefix(t *testing.T) { + var cases = []struct { + s string + prefix []string + result bool + }{ + {s: "", prefix: nil, result: false}, + {s: "", prefix: []string{}, result: false}, + {s: "a", prefix: []string{}, result: false}, + {s: "a", prefix: []string{"a"}, result: true}, + {s: "a", prefix: []string{"aa"}, result: false}, + {s: "aa", prefix: []string{"a"}, result: true}, + } + for _, c := range cases { + result := HasAnyPrefix(c.s, c.prefix) + if result != c.result { + t.Fatalf("got %v, want %v", result, c.result) + } + } +} + func BenchmarkSanitizeURL(b *testing.B) { var bms = []struct { name string |