(expected, actual interface{})
| 1212 | } |
| 1213 | |
| 1214 | func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { |
| 1215 | expectedOpts := reflect.ValueOf(expected) |
| 1216 | actualOpts := reflect.ValueOf(actual) |
| 1217 | |
| 1218 | var expectedFuncs []*runtime.Func |
| 1219 | var expectedNames []string |
| 1220 | for i := 0; i < expectedOpts.Len(); i++ { |
| 1221 | f := runtimeFunc(expectedOpts.Index(i).Interface()) |
| 1222 | expectedFuncs = append(expectedFuncs, f) |
| 1223 | expectedNames = append(expectedNames, funcName(f)) |
| 1224 | } |
| 1225 | var actualFuncs []*runtime.Func |
| 1226 | var actualNames []string |
| 1227 | for i := 0; i < actualOpts.Len(); i++ { |
| 1228 | f := runtimeFunc(actualOpts.Index(i).Interface()) |
| 1229 | actualFuncs = append(actualFuncs, f) |
| 1230 | actualNames = append(actualNames, funcName(f)) |
| 1231 | } |
| 1232 | |
| 1233 | if expectedOpts.Len() != actualOpts.Len() { |
| 1234 | expectedFmt = fmt.Sprintf("%v", expectedNames) |
| 1235 | actualFmt = fmt.Sprintf("%v", actualNames) |
| 1236 | return |
| 1237 | } |
| 1238 | |
| 1239 | for i := 0; i < expectedOpts.Len(); i++ { |
| 1240 | if !isFuncSame(expectedFuncs[i], actualFuncs[i]) { |
| 1241 | expectedFmt = expectedNames[i] |
| 1242 | actualFmt = actualNames[i] |
| 1243 | return |
| 1244 | } |
| 1245 | |
| 1246 | expectedOpt := expectedOpts.Index(i).Interface() |
| 1247 | actualOpt := actualOpts.Index(i).Interface() |
| 1248 | |
| 1249 | ot := reflect.TypeOf(expectedOpt) |
| 1250 | var expectedValues []reflect.Value |
| 1251 | var actualValues []reflect.Value |
| 1252 | if ot.NumIn() == 0 { |
| 1253 | return |
| 1254 | } |
| 1255 | |
| 1256 | for i := 0; i < ot.NumIn(); i++ { |
| 1257 | vt := ot.In(i).Elem() |
| 1258 | expectedValues = append(expectedValues, reflect.New(vt)) |
| 1259 | actualValues = append(actualValues, reflect.New(vt)) |
| 1260 | } |
| 1261 | |
| 1262 | reflect.ValueOf(expectedOpt).Call(expectedValues) |
| 1263 | reflect.ValueOf(actualOpt).Call(actualValues) |
| 1264 | |
| 1265 | for i := 0; i < ot.NumIn(); i++ { |
| 1266 | if expectedArg, actualArg := expectedValues[i].Interface(), actualValues[i].Interface(); !assert.ObjectsAreEqual(expectedArg, actualArg) { |
| 1267 | expectedFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], expectedArg, expectedArg) |
| 1268 | actualFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], actualArg, actualArg) |
| 1269 | return |
| 1270 | } |
| 1271 | } |
no test coverage detected