fix(contrib/log): test case error (#2487)

* fix(contrib/log): test case error

* fix float32

* add nil case
pull/2492/head
jessetang 2 years ago committed by GitHub
parent 2a65502be2
commit 511f1917ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      contrib/log/aliyun/aliyun_test.go
  2. 19
      contrib/log/tencent/tencent_test.go

@ -116,21 +116,22 @@ func TestToString(t *testing.T) {
{"float64", 6.66, "6.66"},
{"max float64", math.MaxFloat64, "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, //nolint:lll
{"float32", float32(6.66), "6.66"},
{"max float32", math.MaxFloat32, "340282346638528860000000000000000000000"},
{"int", int(math.MaxInt64), "9223372036854775807"},
{"max float32", float32(math.MaxFloat32), "340282350000000000000000000000000000000"},
{"int", math.MaxInt64, "9223372036854775807"},
{"uint", uint(math.MaxUint64), "18446744073709551615"},
{"int8", math.MaxInt8, "127"},
{"uint8", math.MaxUint8, "255"},
{"int16", math.MaxInt16, "32767"},
{"uint16", math.MaxUint16, "65535"},
{"int32", math.MaxInt32, "2147483647"},
{"uint32", math.MaxUint32, "4294967295"},
{"int64", math.MaxInt64, "9223372036854775807"},
{"int8", int8(math.MaxInt8), "127"},
{"uint8", uint8(math.MaxUint8), "255"},
{"int16", int16(math.MaxInt16), "32767"},
{"uint16", uint16(math.MaxUint16), "65535"},
{"int32", int32(math.MaxInt32), "2147483647"},
{"uint32", uint32(math.MaxUint32), "4294967295"},
{"int64", int64(math.MaxInt64), "9223372036854775807"},
{"uint64", uint64(math.MaxUint64), "18446744073709551615"},
{"string", "abc", "abc"},
{"bool", false, "false"},
{"[]byte", []byte("abc"), "abc"},
{"struct", struct{ Name string }{}, `{"Name":""}`},
{"nil", nil, ""},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

@ -120,21 +120,22 @@ func TestToString(t *testing.T) {
{"float64", 6.66, "6.66"},
{"max float64", math.MaxFloat64, "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, //nolint:lll
{"float32", float32(6.66), "6.66"},
{"max float32", math.MaxFloat32, "340282346638528860000000000000000000000"},
{"int", int(math.MaxInt64), "9223372036854775807"},
{"max float32", float32(math.MaxFloat32), "340282350000000000000000000000000000000"},
{"int", math.MaxInt64, "9223372036854775807"},
{"uint", uint(math.MaxUint64), "18446744073709551615"},
{"int8", math.MaxInt8, "127"},
{"uint8", math.MaxUint8, "255"},
{"int16", math.MaxInt16, "32767"},
{"uint16", math.MaxUint16, "65535"},
{"int32", math.MaxInt32, "2147483647"},
{"uint32", math.MaxUint32, "4294967295"},
{"int64", math.MaxInt64, "9223372036854775807"},
{"int8", int8(math.MaxInt8), "127"},
{"uint8", uint8(math.MaxUint8), "255"},
{"int16", int16(math.MaxInt16), "32767"},
{"uint16", uint16(math.MaxUint16), "65535"},
{"int32", int32(math.MaxInt32), "2147483647"},
{"uint32", uint32(math.MaxUint32), "4294967295"},
{"int64", int64(math.MaxInt64), "9223372036854775807"},
{"uint64", uint64(math.MaxUint64), "18446744073709551615"},
{"string", "abc", "abc"},
{"bool", false, "false"},
{"[]byte", []byte("abc"), "abc"},
{"struct", struct{ Name string }{}, `{"Name":""}`},
{"nil", nil, ""},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

Loading…
Cancel
Save