marshaler_test.go 746 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package test
  2. import (
  3. "encoding/json"
  4. "encoding"
  5. )
  6. func init() {
  7. jsonMarshaler := json.Marshaler(fakeJsonMarshaler{})
  8. textMarshaler := encoding.TextMarshaler(fakeTextMarshaler{})
  9. marshalCases = append(marshalCases,
  10. fakeJsonMarshaler{},
  11. &jsonMarshaler,
  12. fakeTextMarshaler{},
  13. &textMarshaler,
  14. )
  15. }
  16. type fakeJsonMarshaler struct {
  17. F2 chan []byte
  18. }
  19. func (q fakeJsonMarshaler) MarshalJSON() ([]byte, error) {
  20. return []byte(`""`), nil
  21. }
  22. func (q *fakeJsonMarshaler) UnmarshalJSON(value []byte) error {
  23. return nil
  24. }
  25. type fakeTextMarshaler struct {
  26. F2 chan []byte
  27. }
  28. func (q fakeTextMarshaler) MarshalText() ([]byte, error) {
  29. return []byte(`""`), nil
  30. }
  31. func (q *fakeTextMarshaler) UnmarshalText(value []byte) error {
  32. return nil
  33. }