数据操作升级为基于泛型实现 #10

Merged
zhangdeman merged 8 commits from feature/support_genericity into master 2025-10-13 17:10:54 +08:00
9 changed files with 640 additions and 537 deletions
Showing only changes of commit 059830d87d - Show all commits

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)
})
}