1
0
Fork 0
mirror of https://github.com/vbatts/git-validation.git synced 2024-12-28 16:26:31 +00:00
git-validation/validate/rules_test.go

53 lines
1.1 KiB
Go
Raw Normal View History

package validate
import (
"testing"
)
func TestSanitizeRules(t *testing.T) {
set := []struct {
input string
output []string
}{
{
input: "apples, oranges , bananas",
output: []string{"apples", "oranges", "bananas"},
},
{
input: "apples, oranges , bananas, peaches='with cream'",
output: []string{"apples", "oranges", "bananas", "peaches='with cream'"},
},
}
for i := range set {
filt := SanitizeFilters(set[i].input)
if !StringsSliceEqual(filt, set[i].output) {
t.Errorf("expected output like %v, but got %v", set[i].output, filt)
}
}
}
func TestSliceHelpers(t *testing.T) {
set := []struct {
A, B []string
Equal bool
}{
{
A: []string{"apples", "bananas", "oranges", "mango"},
B: []string{"oranges", "bananas", "apples", "mango"},
Equal: true,
},
{
A: []string{"apples", "bananas", "oranges", "mango"},
B: []string{"waffles"},
Equal: false,
},
}
for i := range set {
got := StringsSliceEqual(set[i].A, set[i].B)
if got != set[i].Equal {
t.Errorf("expected %d A and B comparison to be %t, but got %t", i, set[i].Equal, got)
}
}
}