| 47 | } |
| 48 | |
| 49 | func TestContains(t *testing.T) { |
| 50 | tests := []struct { |
| 51 | name string |
| 52 | inputSlice []string |
| 53 | stringToTest string |
| 54 | expected bool |
| 55 | }{ |
| 56 | { |
| 57 | name: "contains in slice", |
| 58 | inputSlice: []string{"maguro", "otoro", "unagi"}, |
| 59 | stringToTest: "otoro", |
| 60 | expected: true, |
| 61 | }, |
| 62 | { |
| 63 | name: "contains in 1 element slice", |
| 64 | inputSlice: []string{"unagi"}, |
| 65 | stringToTest: "unagi", |
| 66 | expected: true, |
| 67 | }, |
| 68 | { |
| 69 | name: "empty slice", |
| 70 | inputSlice: []string{}, |
| 71 | stringToTest: "otoro", |
| 72 | expected: false, |
| 73 | }, |
| 74 | { |
| 75 | name: "missing in slice", |
| 76 | inputSlice: []string{"maguro", "otoro", "unagi"}, |
| 77 | stringToTest: "tamago", |
| 78 | expected: false, |
| 79 | }, |
| 80 | } |
| 81 | |
| 82 | for _, tt := range tests { |
| 83 | t.Run(tt.name, func(t *testing.T) { |
| 84 | assert.Equal(t, tt.expected, Contains(tt.inputSlice, tt.stringToTest)) |
| 85 | }) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func TestToKebabCase(t *testing.T) { |
| 90 | tests := []struct { |