main
1package sanitize
2
3import "testing"
4
5func TestFilename(t *testing.T) {
6 tests := []struct {
7 input string
8 expected string
9 }{
10 {"simple", "simple"},
11 {"with spaces", "with spaces"},
12 {"with/slash", "with_slash"},
13 {"with\\backslash", "with_backslash"},
14 {"with:colon", "with_colon"},
15 {"with*star", "with_star"},
16 {"with?question", "with_question"},
17 {`with"quote`, "with_quote"},
18 {"with<less", "with_less"},
19 {"with>greater", "with_greater"},
20 {"with|pipe", "with_pipe"},
21 {"multiple///slashes", "multiple_slashes"},
22 {" leading spaces", "leading spaces"},
23 {"trailing spaces ", "trailing spaces"},
24 {"___leading_underscores", "leading_underscores"},
25 {"trailing_underscores___", "trailing_underscores"},
26 {"Camera:Front/Back", "Camera_Front_Back"},
27 {"", ""},
28 }
29
30 for _, tc := range tests {
31 result := Filename(tc.input)
32 if result != tc.expected {
33 t.Errorf("Filename(%q) = %q, want %q", tc.input, result, tc.expected)
34 }
35 }
36}