github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/break/predicate/test/api_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/m4gshm/gollections/break/predicate" 9 "github.com/m4gshm/gollections/break/predicate/eq" 10 "github.com/m4gshm/gollections/break/predicate/less" 11 "github.com/m4gshm/gollections/break/predicate/more" 12 ) 13 14 func Test_Union(t *testing.T) { 15 c, _ := predicate.Union[int]()(100) 16 assert.False(t, c) 17 c, _ = predicate.Union[int](predicate.Xor(eq.To(1), eq.To(1)))(1) 18 assert.False(t, c) 19 c, _ = predicate.Union[int](eq.To(1), less.Than(2))(1) 20 assert.True(t, c) 21 22 condition := predicate.Union[int](less.Than(3), more.Than(-1), predicate.Or[int](eq.To(0), eq.To(1)).Or(eq.To(2))) 23 24 c, _ = condition(1) 25 assert.True(t, c) 26 c, _ = condition(0) 27 assert.True(t, c) 28 c, _ = condition(3) 29 assert.False(t, c) 30 }