Repository: stretchr/testify (go)

Issue:
EqualExportedValues panic when struct contains array 
Hi

```golang
package main

import (
	"github.com/stretchr/testify/assert"
)

type Foo struct {
	Array [2]int
}

func main() {
	a := Foo{[2]int{1, 2}}
	b := Foo{[2]int{2, 1}}
	assert.EqualExportedValues(nil, a, b)
}
```

Will panic with "panic: reflect.MakeSlice of non-slice type"

Reason is there in assertion.go:113 :
```golang
case reflect.Array, reflect.Slice:
	result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
```

reflect.MakeSlice only work with slice, not with Array. Fix could be follow:

```golang
case reflect.Array, reflect.Slice:
	result := reflect.New(expectedType).Elem()
	if expectedKind == reflect.Slice {
		result = reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
	}
```

Or even carry reflect.Array to different switch case

Pull request:
assert.EqualExportedValues: fix handling of arrays
## Summary
<!-- High-level, one sentence summary of what this PR accomplishes -->
In EqualExportedValues, testify treats an Array as a Slice, however, the reflect library throws an error if the type passed to `reflect.MakeSlice` is not a Slice kind. This issue was identified in #1404

The result is a [very simple test](https://go.dev/play/p/Rxk9Z1Cvsx9) such as 
```go
func TestEqualExportedValuesWithArray(t *testing.T) {
	type S struct{ Values [2]int }
	require.EqualExportedValues(t, S{Values: [2]int{1, 2}}, S{Values: [2]int{1, 2}})
}
```

results in a panic

```
panic: reflect.MakeSlice of non-slice type
```

This PR adjusts the offending switch statement in `copyExportedFields` to handle arrays separately, and construct the array using `reflect.New(reflect.ArrayOf(len, type)).Elem()` instead of `reflect.MakeSlice`.

## Changes
<!-- * Description of change 1 -->
- Changed `copyExportedFields` (used by `EqualExportedValues`) to handle Array type separately from Slices as they must be constructed differently.
<!-- * Description of change 2 -->
- Added a test case to `TestEqualExportedValues` to verify an array object can be set on object passed to `EqualExportedValues`.
<!-- ... -->

## Motivation
<!-- Why were the changes necessary. -->
A user was unable to use `EqualExportedValues` if they had an exported array type nested somewhere in their struct.

<!-- ## Example usage (if applicable) -->
A test like this will now pass
```go
func TestEqualExportedValuesWithArray(t *testing.T) {
	type S struct{ Values [2]int }
	require.EqualExportedValues(t, S{Values: [2]int{1, 2}}, S{Values: [2]int{1, 2}})
}
```

## Related issues
<!-- Put `Closes #XXXX` for each issue number this PR fixes/closes -->
Closes #1404 

Patch:
diff --git a/assert/assertions.go b/assert/assertions.go
index c276316..1e55fbf 100644
--- a/assert/assertions.go
+++ b/assert/assertions.go
@@ -115,7 +115,12 @@ func copyExportedFields(expected interface{}) interface{} {
 		return result.Interface()
 
 	case reflect.Array, reflect.Slice:
-		result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
+		var result reflect.Value
+		if expectedKind == reflect.Array {
+			result = reflect.New(reflect.ArrayOf(expectedValue.Len(), expectedType.Elem())).Elem()
+		} else {
+			result = reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
+		}
 		for i := 0; i < expectedValue.Len(); i++ {
 			index := expectedValue.Index(i)
 			if isNil(index) {


Test patch:
diff --git a/assert/assertions_test.go b/assert/assertions_test.go
index e1245b4..9a44f95 100644
--- a/assert/assertions_test.go
+++ b/assert/assertions_test.go
@@ -408,6 +408,11 @@ func TestEqualExportedValues(t *testing.T) {
 	            	+   Exported: (int) 2,
 	            	    notExported: (interface {}) <nil>`,
 		},
+		{
+			value1:        S{[2]int{1, 2}, Nested{2, 3}, 4, Nested{5, 6}},
+			value2:        S{[2]int{1, 2}, Nested{2, nil}, nil, Nested{}},
+			expectedEqual: true,
+		},
 	}
 
 	for _, c := range cases {