type_test.go 830 B

1234567891011121314151617181920212223242526272829303132
  1. package ddm
  2. import (
  3. "encoding/json"
  4. "testing"
  5. )
  6. type message struct {
  7. Name IDName `json:"name"`
  8. Mobile Mobile `json:"mobile"`
  9. IDCard IDCard `json:"id_card"`
  10. PassWord PassWord `json:"password"`
  11. Email Email `json:"email"`
  12. BankCard1 BankCard `json:"bank_card_1"`
  13. BankCard2 BankCard `json:"bank_card_2"`
  14. BankCard3 BankCard `json:"bank_card_3"`
  15. }
  16. func TestMarshalJSON(t *testing.T) {
  17. msg := new(message)
  18. msg.Name = IDName("李鸿章")
  19. msg.Mobile = Mobile("13288887986")
  20. msg.IDCard = IDCard("125252525252525252")
  21. msg.PassWord = PassWord("123456")
  22. msg.Email = Email("xinliangnote@163.com")
  23. msg.BankCard1 = BankCard("6545654565456545")
  24. msg.BankCard2 = BankCard("65485269874569852")
  25. msg.BankCard3 = BankCard("6548526987456985298")
  26. marshal, _ := json.Marshal(msg)
  27. t.Log(string(marshal))
  28. }