map_test.go 304 B

123456789101112131415161718
  1. package test
  2. import (
  3. "github.com/modern-go/reflect2"
  4. "testing"
  5. )
  6. func Test_map(t *testing.T) {
  7. var pInt = func(val int) *int {
  8. return &val
  9. }
  10. valType := reflect2.TypeOf(map[int]int{}).(reflect2.MapType)
  11. m := map[int]int{}
  12. valType.SetIndex(&m, pInt(1), pInt(1))
  13. if m[1] != 1 {
  14. t.Fail()
  15. }
  16. }