2019-10-04 21:47:38 +00:00
|
|
|
package main
|
|
|
|
|
2024-11-14 19:35:26 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
2019-10-04 21:47:38 +00:00
|
|
|
|
|
|
|
func TestUtilEqualSliceString(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
a, b []string
|
|
|
|
expected bool
|
|
|
|
}{
|
|
|
|
// Equal cases
|
|
|
|
{nil, nil, true},
|
|
|
|
{nil, []string{}, true},
|
|
|
|
{[]string{}, nil, true},
|
|
|
|
{[]string{"a"}, []string{"a"}, true},
|
|
|
|
// Inequal cases
|
|
|
|
{nil, []string{"b"}, false},
|
|
|
|
{[]string{"a"}, nil, false},
|
|
|
|
{[]string{"a"}, []string{"b"}, false},
|
|
|
|
{[]string{"a"}, []string{"a", "b"}, false},
|
|
|
|
{[]string{"a", "b"}, []string{"b"}, false},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, c := range cases {
|
2024-11-14 19:35:26 +00:00
|
|
|
c := c
|
|
|
|
|
|
|
|
t.Run(fmt.Sprintf("%v %v", c.a, c.b), func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
actual := EqualSliceString(c.a, c.b)
|
|
|
|
if actual != c.expected {
|
|
|
|
t.Errorf(
|
|
|
|
"EqualSliceString(%v, %v), expected=%v actual=%v",
|
|
|
|
c.a, c.b, c.expected, actual,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
2019-10-04 21:47:38 +00:00
|
|
|
}
|
|
|
|
}
|