常用类型及数据操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
913 B

3 years ago
3 years ago
  1. package helper
  2. import (
  3. "math"
  4. "strings"
  5. "testing"
  6. )
  7. func Test_FloadAdd(t *testing.T) {
  8. // str1 := 4
  9. str2 := "5"
  10. str3 := 6.5
  11. // str4 := 1
  12. ret := FloatAdd(str3, str2)
  13. t.Log(ret)
  14. percentage := "8:2:1"
  15. price := strings.Split(percentage, ":")
  16. ret = FloatAdd(price[0], price[1], price[2])
  17. t.Log(ret)
  18. }
  19. func Test_FloatSub(t *testing.T) {
  20. str1 := 4.25
  21. str2 := "5.33"
  22. ret := FloatSub(str1, str2)
  23. t.Log(ret)
  24. }
  25. func Test_FloatMul(t *testing.T) {
  26. str1 := 4.25
  27. str2 := "5.33"
  28. ret := FloatMul(str1, str2, 1)
  29. t.Log(ret)
  30. }
  31. func Test_FloatQuo(t *testing.T) {
  32. str1 := 6
  33. str2 := "7"
  34. ret := FloatQuo(str1, str2, 3)
  35. t.Log(ret)
  36. ret = math.Ceil(FloatQuo(4500, 3600))
  37. t.Log(ret)
  38. }
  39. // func Test_TenToHex(t *testing.T) {
  40. // str1 := 10664
  41. // ret := TenToHex(str1)
  42. // t.Log(ret)
  43. // }
  44. // func Test_HexToTen(t *testing.T) {
  45. // str := "29B79F0D"
  46. // ret, err := HexToTen(str)
  47. // t.Log(ret, err)
  48. // }