diff options
author | Vazrupe (HyeonGyu Lee) <vazrupe@naver.com> | 2019-09-03 21:20:20 +0900 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-09-05 14:38:47 +0200 |
commit | 5e660947757023434dd7a1ec8b8239c0577fd501 (patch) | |
tree | 5fbdf488a8918cd8e47948ad771e1a350f3fdb07 /tpl/compare/compare_test.go | |
parent | f4e1cb8d05720ac58f7d89b95b8fe275ac632091 (diff) |
tpl: Remove eq argument limitation
Fixes #6237
Diffstat (limited to 'tpl/compare/compare_test.go')
-rw-r--r-- | tpl/compare/compare_test.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tpl/compare/compare_test.go b/tpl/compare/compare_test.go index 2331206b3..fdbcc24bb 100644 --- a/tpl/compare/compare_test.go +++ b/tpl/compare/compare_test.go @@ -145,6 +145,10 @@ func TestCompare(t *testing.T) { n := New(false) + twoEq := func(a, b interface{}) bool { + return n.Eq(a, b) + } + for _, test := range []struct { tstCompareType funcUnderTest func(a, b interface{}) bool @@ -153,7 +157,7 @@ func TestCompare(t *testing.T) { {tstLt, n.Lt}, {tstGe, n.Ge}, {tstLe, n.Le}, - {tstEq, n.Eq}, + {tstEq, twoEq}, {tstNe, n.Ne}, } { doTestCompare(t, test.tstCompareType, test.funcUnderTest) @@ -237,6 +241,28 @@ func doTestCompare(t *testing.T, tp tstCompareType, funcUnderTest func(a, b inte } } +func TestEqualExtend(t *testing.T) { + t.Parallel() + c := qt.New(t) + + ns := New(false) + + for _, test := range []struct { + first interface{} + others []interface{} + expect bool + }{ + {1, []interface{}{1, 2}, true}, + {1, []interface{}{2, 1}, true}, + {1, []interface{}{2, 3}, false}, + } { + + result := ns.Eq(test.first, test.others...) + + c.Assert(result, qt.Equals, test.expect) + } +} + func TestCase(t *testing.T) { c := qt.New(t) n := New(true) |