github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/collection/immutable/test/keys_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 6 "github.com/m4gshm/gollections/collection/immutable" 7 "github.com/m4gshm/gollections/collection/immutable/ordered" 8 "github.com/m4gshm/gollections/convert/ptr" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func Test_MapKeys_Zero_Safety(t *testing.T) { 13 var collection immutable.MapKeys[int, string] 14 15 collection.Loop() 16 collection.Head() 17 collection.Convert(func(i int) int { return i }) 18 collection.Filter(func(_ int) bool { return true }) 19 collection.Slice() 20 collection.Reduce(func(_, _ int) int { return 0 }) 21 s := collection.String() 22 assert.Equal(t, "[]", s) 23 24 } 25 26 func Test_Map_Zero(t *testing.T) { 27 var collection ordered.Map[int, string] 28 29 collection.Loop() 30 ptr.Of(collection.Head()).Next() 31 collection.Convert(func(_ int, _ string) (int, string) { return 0, "" }) 32 collection.Filter(func(_ int, _ string) bool { return true }) 33 collection.Map() 34 collection.Reduce(func(_, _ int, _, _ string) (int, string) { return 0, "" }) 35 s := collection.String() 36 assert.Equal(t, "[]", s) 37 38 }