diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-06-19 23:44:34 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-06-19 23:44:34 +0200 |
commit | a39e266ddeb9d11b9f23f50a0124c56e3414563c (patch) | |
tree | 7dbbbfadabe298e72adea97aa145e0d62bdf3cc3 | |
parent | 56b989f3cc6d64e9b43b7fa07f6dac7323c80ce0 (diff) | |
download | refcat-a39e266ddeb9d11b9f23f50a0124c56e3414563c.tar.gz refcat-a39e266ddeb9d11b9f23f50a0124c56e3414563c.zip |
url: add test
-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 |