main_test.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package yu_proto
  2. import (
  3. "fmt"
  4. yu_hex "gogs.qqck.cn/s/tools/hex"
  5. yu_rand "gogs.qqck.cn/s/tools/rand"
  6. "testing"
  7. )
  8. func TestProtobuf_Set(t *testing.T) {
  9. j_pro := New()
  10. j_pro.SetString("111", "21")
  11. j_pro.SetString("111", "20")
  12. j_pro.SetString(yu_rand.SEx(16), "99")
  13. j_pro.SetInt64(2, "3", "2", "6")
  14. j_pro.SetBool(true, "3", "2", "2")
  15. j_pro.SetBool(false, "3", "2", "4")
  16. j_pro.SetFloat64(1.7976931348623157, "3", "2", "6")
  17. j_pro.SetFloat32(3.4020000001, "3", "2", "1")
  18. fmt.Println(j_pro.Json())
  19. fmt.Println(yu_hex.Upper(j_pro.Bytes()))
  20. j_pro.SetString(yu_rand.SEx(16), "3", "1", 6)
  21. j_pro.SetFloat64(1.7976931348623157, "3", "1", 2)
  22. fmt.Println(j_pro.Json())
  23. fmt.Println(yu_hex.Upper(j_pro.Bytes()))
  24. j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 0, "1")
  25. j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 0, "2", "3")
  26. j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 0, "3", 3, "4")
  27. j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 1, "1", "5")
  28. j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 1, "2", "6")
  29. j_pro.SetString(yu_rand.SEx(16), "6", "1", "10", 1, "3", 3, "7")
  30. fmt.Println(j_pro.Json())
  31. fmt.Println(yu_hex.Upper(j_pro.Bytes()))
  32. j_pro.SetString(yu_rand.SEx(16), "6", 0, "1")
  33. j_pro.SetString(yu_rand.SEx(16), "6", 0, "2", "3")
  34. j_pro.SetString(yu_rand.SEx(16), "6", 0, "3", 3, "4")
  35. j_pro.SetString(yu_rand.SEx(16), "6", 1, "1", "5")
  36. j_pro.SetString(yu_rand.SEx(16), "6", 1, "2", "6")
  37. j_pro.SetString(yu_rand.SEx(16), "6", 1, "3", 3, "7")
  38. fmt.Println(j_pro.Json())
  39. fmt.Println(yu_hex.Upper(j_pro.Bytes()))
  40. j_pro.SetString(yu_rand.SEx(16), "6", 0, 0, "1")
  41. j_pro.SetString(yu_rand.SEx(16), "6", 0, 0, "2", "3")
  42. j_pro.SetString(yu_rand.SEx(16), "6", 0, 0, "3", 3, "4")
  43. fmt.Println(j_pro.Json())
  44. fmt.Println(yu_hex.Upper(j_pro.Bytes()))
  45. }