You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

http_test.go 506 B

1234567891011121314151617181920212223242526272829303132
  1. package http2
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. )
  6. func Test_objectToStringMap(t *testing.T) {
  7. Convey("包含指针", t, func() {
  8. type A struct {
  9. Val *int `json:"Val,omitempty"`
  10. Nil *int `json:"Nil,omitempty"`
  11. Omit *int `json:"Omit"`
  12. }
  13. v := 10
  14. a := A{
  15. Val: &v,
  16. Nil: nil,
  17. Omit: nil,
  18. }
  19. mp, err := objectToStringMap(a, "json")
  20. So(err, ShouldBeNil)
  21. So(mp, ShouldResemble, map[string]string{
  22. "Val": "10",
  23. "Omit": "",
  24. })
  25. })
  26. }