MCPcopy
hub / github.com/stretchr/testify / Test_Arguments_Diff_WithArgMatcher

Function Test_Arguments_Diff_WithArgMatcher

mock/mock_test.go:2002–2025  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2000}
2001
2002func Test_Arguments_Diff_WithArgMatcher(t *testing.T) {
2003 t.Parallel()
2004
2005 matchFn := func(a int) bool {
2006 return a == 123
2007 }
2008 var args = Arguments([]interface{}{"string", MatchedBy(matchFn), true})
2009
2010 diff, count := args.Diff([]interface{}{"string", 124, true})
2011 assert.Equal(t, 1, count)
2012 assert.Contains(t, diff, `(int=124) not matched by func(int) bool`)
2013
2014 diff, count = args.Diff([]interface{}{"string", false, true})
2015 assert.Equal(t, 1, count)
2016 assert.Contains(t, diff, `(bool=false) not matched by func(int) bool`)
2017
2018 diff, count = args.Diff([]interface{}{"string", 123, false})
2019 assert.Equal(t, 1, count)
2020 assert.Contains(t, diff, `(int=123) matched by func(int) bool`)
2021
2022 diff, count = args.Diff([]interface{}{"string", 123, true})
2023 assert.Equal(t, 0, count)
2024 assert.Contains(t, diff, `No differences.`)
2025}
2026
2027func Test_Arguments_Assert(t *testing.T) {
2028 t.Parallel()

Callers

nothing calls this directly

Calls 5

EqualFunction · 0.92
ContainsFunction · 0.92
ArgumentsTypeAlias · 0.85
MatchedByFunction · 0.85
DiffMethod · 0.80

Tested by

no test coverage detected