1
0
mirror of https://github.com/taigrr/wtf synced 2026-03-29 16:55:23 -07:00

Add utils.Includes() helper function

This commit is contained in:
Chris Cummer
2019-08-20 16:39:15 -07:00
parent faf365baa1
commit c832db9ddb
3 changed files with 85 additions and 17 deletions

View File

@@ -9,8 +9,35 @@ import (
)
func Test_DoesNotInclude(t *testing.T) {
Equal(t, true, DoesNotInclude([]string{"cat", "dog", "rat"}, "bat"))
Equal(t, false, DoesNotInclude([]string{"cat", "dog", "rat"}, "dog"))
tests := []struct {
name string
strs []string
val string
expected bool
}{
{
name: "when included",
strs: []string{"a", "b", "c"},
val: "b",
expected: false,
},
{
name: "when not included",
strs: []string{"a", "b", "c"},
val: "f",
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := DoesNotInclude(tt.strs, tt.val)
if tt.expected != actual {
t.Errorf("\nexpected: %t\n got: %t", tt.expected, actual)
}
})
}
}
func Test_ExecuteCommand(t *testing.T) {
@@ -50,6 +77,38 @@ func Test_FindMatch(t *testing.T) {
Equal(t, expected, result)
}
func Test_Includes(t *testing.T) {
tests := []struct {
name string
strs []string
val string
expected bool
}{
{
name: "when included",
strs: []string{"a", "b", "c"},
val: "b",
expected: true,
},
{
name: "when not included",
strs: []string{"a", "b", "c"},
val: "f",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := Includes(tt.strs, tt.val)
if tt.expected != actual {
t.Errorf("\nexpected: %t\n got: %t", tt.expected, actual)
}
})
}
}
func Test_ReadFileBytes(t *testing.T) {
tests := []struct {
name string