mirror of https://github.com/stretchr/testify.git
Combine switch cases, difference wrapped in if statement
parent
2f7efa2451
commit
4ae48e988c
|
@ -114,20 +114,13 @@ func copyExportedFields(expected interface{}) interface{} {
|
||||||
result.Elem().Set(reflect.ValueOf(unexportedRemoved))
|
result.Elem().Set(reflect.ValueOf(unexportedRemoved))
|
||||||
return result.Interface()
|
return result.Interface()
|
||||||
|
|
||||||
case reflect.Array:
|
case reflect.Array, reflect.Slice:
|
||||||
result := reflect.New(reflect.ArrayOf(expectedValue.Len(), expectedType.Elem())).Elem()
|
var result reflect.Value
|
||||||
for i := 0; i < expectedValue.Len(); i++ {
|
if expectedKind == reflect.Array {
|
||||||
index := expectedValue.Index(i)
|
result = reflect.New(reflect.ArrayOf(expectedValue.Len(), expectedType.Elem())).Elem()
|
||||||
if isNil(index) {
|
} else {
|
||||||
continue
|
result = reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
|
||||||
}
|
|
||||||
unexportedRemoved := copyExportedFields(index.Interface())
|
|
||||||
result.Index(i).Set(reflect.ValueOf(unexportedRemoved))
|
|
||||||
}
|
}
|
||||||
return result.Interface()
|
|
||||||
|
|
||||||
case reflect.Slice:
|
|
||||||
result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
|
|
||||||
for i := 0; i < expectedValue.Len(); i++ {
|
for i := 0; i < expectedValue.Len(); i++ {
|
||||||
index := expectedValue.Index(i)
|
index := expectedValue.Index(i)
|
||||||
if isNil(index) {
|
if isNil(index) {
|
||||||
|
|
Loading…
Reference in New Issue