mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-06 07:26:53 +08:00

* anyutil test * fix:delete debug * unit test utils * unit test * strUtil unit test * fix;4, 6, 9, 11 Month determination error * fix:The last digit of ID number is x, and the weighted sum comparison condition is wrong * test * test * docs * fix:docs * idcard test * test unit * no message * docs update * 单元测试覆盖 --------- Co-authored-by: libin <libinjob@163.com> Co-authored-by: 李斌 <libin1-hj@huafang.com>
40 lines
819 B
Go
40 lines
819 B
Go
package anyUtil
|
|
|
|
import "testing"
|
|
|
|
func TestAnyToStr(t *testing.T) {
|
|
iPtr := 90
|
|
testCases := []struct {
|
|
input interface{}
|
|
expected string
|
|
}{
|
|
{"hello", "hello"},
|
|
{123, "123"},
|
|
{int8(8), "8"},
|
|
{int16(16), "16"},
|
|
{int32(32), "32"},
|
|
{int64(64), "64"},
|
|
{uint(10), "10"},
|
|
{uint8(80), "80"},
|
|
{uint16(160), "160"},
|
|
{uint32(320), "320"},
|
|
{uint64(640), "640"},
|
|
{float32(3.14159), "3.14159"},
|
|
{float64(2.71828), "2.71828"},
|
|
{complex64(1 + 2i), "(1+2i)"},
|
|
{complex128(3 + 4i), "(3+4i)"},
|
|
{(*int)(nil), ""},
|
|
{&iPtr, "90"},
|
|
{true, "true"},
|
|
{nil, ""},
|
|
{make(chan int), ""},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
result := AnyToStr(testCase.input)
|
|
if result != testCase.expected {
|
|
t.Errorf("Unexpected result. Expected: %v, but got: %v", testCase.expected, result)
|
|
}
|
|
}
|
|
}
|