File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package genericz
22
33func Zero [T interface {}](_ T ) (zero T ) { return zero } //nolint:ireturn
44
5+ func SliceContentZero [T interface {}](_ []T ) (zero T ) { return zero } //nolint:ireturn
6+
57func IsZero [T comparable ](v T ) bool {
68 var zero T
79 return v == zero
Original file line number Diff line number Diff line change @@ -20,6 +20,26 @@ func TestZero(t *testing.T) {
2020 })
2121}
2222
23+ func TestSliceContentZero (t * testing.T ) {
24+ t .Parallel ()
25+
26+ t .Run ("success()" , func (t * testing.T ) {
27+ t .Parallel ()
28+ {
29+ expected := "1"
30+ if actual := genericz .SliceContentZero ([]string {expected }); actual != "" {
31+ t .Errorf ("❌: genericz.SliceContentZero([]string{%q}): %v" , expected , actual )
32+ }
33+ }
34+ {
35+ expected := 1
36+ if actual := genericz .SliceContentZero ([]int {expected }); actual != 0 {
37+ t .Errorf ("❌: genericz.SliceContentZero([]int{%d}): %v" , expected , actual )
38+ }
39+ }
40+ })
41+ }
42+
2343func TestIsZero (t * testing.T ) {
2444 t .Parallel ()
2545
You can’t perform that action at this time.
0 commit comments