-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
Prerequisite
// ConvertibleTo reports whether a value of the type is convertible to type u.
// Even if ConvertibleTo returns true, the conversion may still panic.
// For example, a slice of type []T is convertible to *[N]T,
// but the conversion will panic if its length is less than N.
ConvertibleTo(u Type) boolExample
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEqualValues(t *testing.T) {
a := []int{1, 2}
b := (*[3]int)(nil)
assert.EqualValues(t, a, b)
}Result
=== RUN TestEqualValues
--- FAIL: TestEqualValues (0.00s)
panic: reflect: cannot convert slice with length 2 to pointer to array with length 3 [recovered]
panic: reflect: cannot convert slice with length 2 to pointer to array with length 3
P.S. Inspired by Antonboom/testifylint#88
brackendawson