github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/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/predicate"
     9  	"github.com/m4gshm/gollections/predicate/eq"
    10  	"github.com/m4gshm/gollections/predicate/less"
    11  	"github.com/m4gshm/gollections/predicate/more"
    12  )
    13  
    14  func Test_Union(t *testing.T) {
    15  	assert.False(t, predicate.Union[int]()(100))
    16  	assert.False(t, predicate.Union[int](predicate.Xor(eq.To(1), eq.To(1)))(1))
    17  	assert.True(t, predicate.Union[int](eq.To(1), less.Than(2))(1))
    18  
    19  	condition := predicate.Union[int](less.Than(3), more.Than(-1), predicate.Or[int](eq.To(0), eq.To(1)).Or(eq.To(2)))
    20  
    21  	assert.True(t, condition(1))
    22  	assert.True(t, condition(0))
    23  	assert.False(t, condition(3))
    24  }