github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/eval/vals/equal_test.go (about) 1 package vals 2 3 import ( 4 "testing" 5 6 "github.com/u-root/u-root/cmds/core/elvish/tt" 7 ) 8 9 type customEqualer struct{ ret bool } 10 11 func (c customEqualer) Equal(interface{}) bool { return c.ret } 12 13 type customStruct struct{ a, b string } 14 15 var equalTests = tt.Table{ 16 Args(customEqualer{true}, 2).Rets(true), 17 Args(customEqualer{false}, 2).Rets(false), 18 Args(true, true).Rets(true), 19 Args(true, false).Rets(false), 20 Args("lorem", "lorem").Rets(true), 21 Args("lorem", "ipsum").Rets(false), 22 Args(MakeList("a", "b"), MakeList("a", "b")).Rets(true), 23 Args(MakeList("a", "b"), MakeList("a")).Rets(false), 24 Args(MakeList("a", "b"), MakeList("a", "c")).Rets(false), 25 Args(MakeMapFromKV("k", "v"), MakeMapFromKV("k", "v")).Rets(true), 26 Args(MakeMapFromKV("k", "v"), MakeMapFromKV("k2", "v")).Rets(false), 27 Args(MakeMapFromKV("k", "v", "k2", "v2"), MakeMapFromKV("k", "v")).Rets(false), 28 Args(&customStruct{"a", "b"}, &customStruct{"a", "b"}).Rets(true), 29 } 30 31 func TestEqual(t *testing.T) { 32 tt.Test(t, tt.Fn("Equal", Equal), equalTests) 33 }