reflect: Convert() for integer and float types

This commit is contained in:
Damian Gryski
2023-03-10 16:33:32 -08:00
committed by Ayke
parent 13fb5aa7e7
commit 72c7adf94a
2 changed files with 100 additions and 1 deletions
+9
View File
@@ -572,6 +572,15 @@ func TestAssignableTo(t *testing.T) {
}
}
func TestConvert(t *testing.T) {
v := ValueOf(int64(3))
c := v.Convert(TypeOf(byte(0)))
if c.Type().Kind() != Uint8 || c.Uint() != 3 {
t.Errorf("Conver(uint64 -> byte failed: kind=%v, value=%d", c.Type().Kind().String(), c.Uint())
}
}
func equal[T comparable](a, b []T) bool {
if len(a) != len(b) {
return false