| 2000 | } |
| 2001 | |
| 2002 | func 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 | |
| 2027 | func Test_Arguments_Assert(t *testing.T) { |
| 2028 | t.Parallel() |