dump_test.go 929 B

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