dump_test.go 866 B

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