dump_test.go 805 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package util
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. type Struct1 struct {
  7. Name string
  8. secret string `dump:"ignore"`
  9. Codes []string
  10. Config map[string]*Address
  11. Age uint
  12. }
  13. type Address struct {
  14. Street string
  15. City string
  16. }
  17. func (address Address) String() string {
  18. return Dump(address)
  19. }
  20. // TestDump test
  21. func TestDump(t *testing.T) {
  22. t.Logf("dump string(TEST) %s\n", Dump("TEST"))
  23. t.Logf("dump int(12) %s\n", Dump(12))
  24. config := make(map[string]*Address)
  25. config["kampung"] = &Address{"Jalan", "Solo"}
  26. config["rumah"] = &Address{"Kampret1", "Jakarta"}
  27. config["kantor"] = &Address{"Kampret2", "Jakarta"}
  28. t.Logf("dump Struct1{}\n%s\n", Dump(Struct1{"seno", "secret",
  29. []string{"sono", "keling"},
  30. config,
  31. 17}))
  32. t.Logf("fmt.Sprintf %s", fmt.Sprintf("HERE\n%v", &Address{"seno", "solo"}))
  33. }