feat: ToBasePtrValue增加单元测试

This commit is contained in:
2025-10-13 12:00:51 +08:00
parent 20d2912274
commit 059830d87d

View File

@ -30,3 +30,20 @@ func TestToBaseValue(t *testing.T) {
So(reflect.TypeOf(res.Value).Kind(), ShouldNotEqual, reflect.Uint32) So(reflect.TypeOf(res.Value).Kind(), ShouldNotEqual, reflect.Uint32)
}) })
} }
func TestToBaseValuePtr(t *testing.T) {
Convey("测试ToBasePtrValue - uint64 转换成功", t, func() {
res := ToBaseValuePtr[uint64]("12345")
So(res.Err, ShouldBeNil)
So(*res.Value, ShouldEqual, uint64(12345))
So(reflect.TypeOf(res.Value).Kind(), ShouldEqual, reflect.Ptr)
So(reflect.TypeOf(res.Value).Elem().Kind(), ShouldEqual, reflect.Uint64)
})
Convey("测试ToBasePtrValue - uint64 转换失败", t, func() {
res := ToBaseValuePtr[uint64]("s12345")
So(res.Err, ShouldNotBeNil)
So(res.Value, ShouldBeNil)
So(reflect.TypeOf(res.Value).Kind(), ShouldEqual, reflect.Ptr)
So(reflect.TypeOf(res.Value).Elem().Kind(), ShouldEqual, reflect.Uint64)
})
}