Skip to content

Commit c08932c

Browse files
committed
Add flag test
1 parent 219a55d commit c08932c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

flag_slice_base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (i *SliceBase[T, C, VC]) Serialize() string {
8080
// Value returns the slice of values set by this flag
8181
func (i *SliceBase[T, C, VC]) Value() []T {
8282
if i.slice == nil {
83-
return []T{}
83+
return nil
8484
}
8585
return *i.slice
8686
}

flag_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,4 +3036,9 @@ func TestSliceValuesNil(t *testing.T) {
30363036
assert.Equal(t, []int64(nil), NewIntSlice().Value())
30373037
assert.Equal(t, []uint64(nil), NewUintSlice().Value())
30383038
assert.Equal(t, []string(nil), NewStringSlice().Value())
3039+
3040+
assert.Equal(t, []float64(nil), (&FloatSlice{}).Value())
3041+
assert.Equal(t, []int64(nil), (&IntSlice{}).Value())
3042+
assert.Equal(t, []uint64(nil), (&UintSlice{}).Value())
3043+
assert.Equal(t, []string(nil), (&StringSlice{}).Value())
30393044
}

0 commit comments

Comments
 (0)