github.com/YousefHaggyHeroku/pack@v1.5.5/internal/slices/slices_test.go (about) 1 package slices_test 2 3 import ( 4 "testing" 5 6 "github.com/sclevine/spec" 7 8 "github.com/YousefHaggyHeroku/pack/internal/slices" 9 h "github.com/YousefHaggyHeroku/pack/testhelpers" 10 ) 11 12 func TestMapString(t *testing.T) { 13 spec.Run(t, "Slices", func(t *testing.T, when spec.G, it spec.S) { 14 var ( 15 assert = h.NewAssertionManager(t) 16 ) 17 18 when("#MapString", func() { 19 it("maps each value", func() { 20 input := []string{"hello", "1", "2", "world"} 21 expected := []string{"hello.", "1.", "2.", "world."} 22 fn := func(v string) string { 23 return v + "." 24 } 25 26 output := slices.MapString(input, fn) 27 assert.Equal(output, expected) 28 }) 29 }) 30 }) 31 }