| 6 | ) |
| 7 | |
| 8 | func TestValidExt(t *testing.T) { |
| 9 | tests := []struct { |
| 10 | exts []string |
| 11 | ext string |
| 12 | expected bool |
| 13 | }{ |
| 14 | { |
| 15 | exts: []string{".txt", ".go", ".html"}, |
| 16 | ext: ".txt", |
| 17 | expected: true, |
| 18 | }, |
| 19 | { |
| 20 | exts: []string{".txt", ".go", ".html"}, |
| 21 | ext: "txt", |
| 22 | expected: true, |
| 23 | }, |
| 24 | { |
| 25 | exts: []string{"txt", "go", "html"}, |
| 26 | ext: ".txt", |
| 27 | expected: true, |
| 28 | }, |
| 29 | { |
| 30 | exts: []string{"txt", "go", "html"}, |
| 31 | ext: "txt", |
| 32 | expected: true, |
| 33 | }, |
| 34 | { |
| 35 | exts: []string{".TXT", ".Go", ".HTML"}, |
| 36 | ext: ".txt", |
| 37 | expected: true, |
| 38 | }, |
| 39 | { |
| 40 | exts: []string{".txt", ".go", ".html"}, |
| 41 | ext: ".js", |
| 42 | expected: false, |
| 43 | }, |
| 44 | { |
| 45 | exts: []string{".txt", ".go", ".html"}, |
| 46 | ext: "js", |
| 47 | expected: false, |
| 48 | }, |
| 49 | { |
| 50 | exts: []string{}, |
| 51 | ext: ".txt", |
| 52 | expected: false, |
| 53 | }, |
| 54 | { |
| 55 | exts: []string{".txt", ".go", ".html"}, |
| 56 | ext: "", |
| 57 | expected: false, |
| 58 | }, |
| 59 | { |
| 60 | exts: []string{".txt", ".go", ".html"}, |
| 61 | ext: ".", |
| 62 | expected: false, |
| 63 | }, |
| 64 | { |
| 65 | exts: []string{".txt", ".go", ".html"}, |