| 2227 | } |
| 2228 | |
| 2229 | func TestArgumentMatcherToPrintMismatch(t *testing.T) { |
| 2230 | t.Parallel() |
| 2231 | |
| 2232 | defer func() { |
| 2233 | if r := recover(); r != nil { |
| 2234 | matchingExp := regexp.MustCompile( |
| 2235 | `\s+mock: Unexpected Method Call\s+-*\s+GetTime\(int\)\s+0: 1\s+The closest call I have is:\s+GetTime\(mock.argumentMatcher\)\s+0: mock.argumentMatcher\{.*?\}\s+Diff:.*\(int=1\) not matched by func\(int\) bool\nat: \[[^\]]+mock\/mock_test.go`) |
| 2236 | assert.Regexp(t, matchingExp, r) |
| 2237 | } |
| 2238 | }() |
| 2239 | |
| 2240 | m := new(timer) |
| 2241 | m.On("GetTime", MatchedBy(func(i int) bool { return false })).Return("SomeTime").Once() |
| 2242 | |
| 2243 | res := m.GetTime(1) |
| 2244 | require.Equal(t, "SomeTime", res) |
| 2245 | m.AssertExpectations(t) |
| 2246 | } |
| 2247 | |
| 2248 | func TestArgumentMatcherToPrintMismatchWithReferenceType(t *testing.T) { |
| 2249 | t.Parallel() |