feat: 相关操作升级为泛型实现

This commit is contained in:
2025-10-13 17:05:00 +08:00
parent 80b5e4e7cc
commit 50d2d6c7bb
18 changed files with 316 additions and 1354 deletions

View File

@ -16,14 +16,14 @@ import (
func TestToBaseValue(t *testing.T) {
Convey("测试ToBaseValue - uint64 转换成功", t, func() {
res := ToBaseValue[uint64]("12345")
res := ToBaseTypeValue[uint64]("12345")
So(res.Err, ShouldBeNil)
So(res.Value, ShouldEqual, uint64(12345))
So(reflect.TypeOf(res.Value).Kind(), ShouldEqual, reflect.Uint64)
So(reflect.TypeOf(res.Value).Kind(), ShouldNotEqual, reflect.Uint32)
})
Convey("测试ToBaseValue - uint64 转换失败", t, func() {
res := ToBaseValue[uint64]("s12345")
res := ToBaseTypeValue[uint64]("s12345")
So(res.Err, ShouldNotBeNil)
So(res.Value, ShouldEqual, 0)
So(reflect.TypeOf(res.Value).Kind(), ShouldEqual, reflect.Uint64)