]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/reflect/all_test.go
[dev.typeparams] all: merge master (798ec73) into dev.typeparams
[gostls13.git] / src / reflect / all_test.go
index e3faa31c1f7559710dc88c2766552b34fd5faf65..5e5e4c1e6040893688f9c19d18b6863483553ae2 100644 (file)
@@ -4305,6 +4305,9 @@ func TestConvert(t *testing.T) {
 
                // vout1 represents the in value converted to the in type.
                v1 := tt.in
+               if !v1.CanConvert(t1) {
+                       t.Errorf("ValueOf(%T(%[1]v)).CanConvert(%s) = false, want true", tt.in.Interface(), t1)
+               }
                vout1 := v1.Convert(t1)
                out1 := vout1.Interface()
                if vout1.Type() != tt.in.Type() || !DeepEqual(out1, tt.in.Interface()) {
@@ -4312,6 +4315,9 @@ func TestConvert(t *testing.T) {
                }
 
                // vout2 represents the in value converted to the out type.
+               if !v1.CanConvert(t2) {
+                       t.Errorf("ValueOf(%T(%[1]v)).CanConvert(%s) = false, want true", tt.in.Interface(), t2)
+               }
                vout2 := v1.Convert(t2)
                out2 := vout2.Interface()
                if vout2.Type() != tt.out.Type() || !DeepEqual(out2, tt.out.Interface()) {
@@ -4372,6 +4378,9 @@ func TestConvertPanic(t *testing.T) {
        if !v.Type().ConvertibleTo(pt) {
                t.Errorf("[]byte should be convertible to *[8]byte")
        }
+       if v.CanConvert(pt) {
+               t.Errorf("slice with length 4 should not be convertible to *[8]byte")
+       }
        shouldPanic("reflect: cannot convert slice with length 4 to pointer to array with length 8", func() {
                _ = v.Convert(pt)
        })