Skip to content

Commit 423cfce

Browse files
committed
add test for check.nonEmpty
1 parent d04b7b1 commit 423cfce

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

check/check_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,35 @@ func TestNa(t *testing.T) {
1919
}
2020
}
2121
}
22+
23+
func TestNonEmpty(t *testing.T) {
24+
tests := []struct {
25+
strings []string
26+
want []string
27+
}{
28+
{[]string{""}, nil},
29+
{[]string{"", ""}, nil},
30+
{[]string{"a", ""}, []string{"a"}},
31+
{[]string{"a", "b"}, []string{"a", "b"}},
32+
{[]string{"", "b"}, []string{"b"}},
33+
}
34+
for _, test := range tests {
35+
if got := nonEmpty(test.strings...); !equal(got, test.want) {
36+
37+
}
38+
}
39+
}
40+
41+
// equal tells whether a and b contain the same elements. A nil argument is
42+
// equivalent to an empty slice.
43+
func equal(a, b []string) bool {
44+
if len(a) != len(b) {
45+
return false
46+
}
47+
for i, v := range a {
48+
if v != b[i] {
49+
return false
50+
}
51+
}
52+
return true
53+
}

0 commit comments

Comments
 (0)