feat: ToBasePtrValue增加单元测试

This commit is contained in:
zhangdeman committed 2025-10-13 12:00:51 +08:00
1 parent 20d2912274
commit 059830d87d
1 file changed
+17
+17
View File
@@ -30,3 +30,20 @@ func TestToBaseValue(t *testing.T) {
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)
})
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.