@@ -204,6 +204,13 @@ func TestConvert(t *testing.T) {
204204 "float64 to uint64" : MapTest [float64 , uint64 ]{Input : 42 , ExpectedOutput : 42 },
205205 "float64 to float32" : MapTest [float64 , float32 ]{Input : 42 , ExpectedOutput : 42 },
206206 "float64 to float64" : MapTest [float64 , float64 ]{Input : 42 , ExpectedOutput : 42 },
207+
208+ "uintptr to uint" : MapTest [uintptr , uint ]{Input : uintptr (42 ), ExpectedOutput : uint (42 )},
209+ "uint to uintptr" : MapTest [uint , uintptr ]{Input : uint (42 ), ExpectedOutput : uintptr (42 )},
210+ "int8 to uintptr" : MapTest [int8 , uintptr ]{Input : int8 (42 ), ExpectedOutput : uintptr (42 )},
211+ "int16 to uintptr" : MapTest [int16 , uintptr ]{Input : int16 (42 ), ExpectedOutput : uintptr (42 )},
212+ "int32 to uintptr" : MapTest [int32 , uintptr ]{Input : int32 (42 ), ExpectedOutput : uintptr (42 )},
213+ "int64 to uintptr" : MapTest [int64 , uintptr ]{Input : int64 (42 ), ExpectedOutput : uintptr (42 )},
207214 } {
208215 t .Run (name , func (t * testing.T ) {
209216 c .Run (t )
@@ -310,6 +317,11 @@ func TestConvert(t *testing.T) {
310317 Input : float64 (math .MaxUint64 * 1.01 ),
311318 ExpectedError : safecast .ErrExceedMaximumValue ,
312319 },
320+
321+ "upper bound overflows for uintptr" : MapTest [float64 , uintptr ]{
322+ Input : float64 (math .MaxUint64 * 1.01 ), // uintptr is at least uint32, but can be uint64
323+ ExpectedError : safecast .ErrExceedMaximumValue ,
324+ },
313325 } {
314326 t .Run (name , func (t * testing.T ) {
315327 c .Run (t )
@@ -370,6 +382,11 @@ func TestConvert(t *testing.T) {
370382 Input : - 42 ,
371383 ExpectedError : safecast .ErrExceedMinimumValue ,
372384 },
385+
386+ "negative overflows uintptr" : MapTest [int , uintptr ]{
387+ Input : - 42 ,
388+ ExpectedError : safecast .ErrExceedMinimumValue ,
389+ },
373390 } {
374391 t .Run (name , func (t * testing.T ) {
375392 c .Run (t )
0 commit comments