File size: 292 Bytes
6380833 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package slicesx
import (
"fmt"
"reflect"
"testing"
)
func TestMap(t *testing.T) {
s := []int{1, 2, 3}
expected := []string{"1", "2", "3"}
actual := Map(s, func(v int) string {
return fmt.Sprintf("%d", v)
})
if !reflect.DeepEqual(expected, actual) {
t.Fatal("map failed")
}
}
|