map_test.go 756 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package test
  2. import "math/big"
  3. func init() {
  4. nilMap := map[string]string(nil)
  5. marshalCases = append(marshalCases,
  6. map[string]interface{}{"abc": 1},
  7. map[string]MyInterface{"hello": MyString("world")},
  8. map[*big.Float]string{big.NewFloat(1.2): "2"},
  9. map[string]interface{}{
  10. "3": 3,
  11. "1": 1,
  12. "2": 2,
  13. },
  14. map[uint64]interface{}{
  15. uint64(1): "a",
  16. uint64(2): "a",
  17. uint64(4): "a",
  18. },
  19. nilMap,
  20. &nilMap,
  21. )
  22. unmarshalCases = append(unmarshalCases, unmarshalCase{
  23. ptr: (*map[string]string)(nil),
  24. input: `{"k\"ey": "val"}`,
  25. }, unmarshalCase{
  26. ptr: (*map[string]string)(nil),
  27. input: `null`,
  28. })
  29. }
  30. type MyInterface interface {
  31. Hello() string
  32. }
  33. type MyString string
  34. func (ms MyString) Hello() string {
  35. return string(ms)
  36. }