github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/break/predicate/internal/test/predicate_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 6 "github.com/m4gshm/gollections/break/predicate/less" 7 "github.com/m4gshm/gollections/break/predicate/more" 8 "github.com/m4gshm/gollections/break/predicate/one" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func Test_lessThan(t *testing.T) { 13 lessC := less.Than("C") 14 A, _ := lessC("A") 15 assert.True(t, A) 16 B, _ := lessC("B") 17 assert.True(t, B) 18 C, _ := lessC("C") 19 assert.False(t, C) 20 D, _ := lessC("D") 21 assert.False(t, D) 22 } 23 24 func Test_lessOrEq(t *testing.T) { 25 lessOrEqC := less.OrEq("C") 26 A, _ := lessOrEqC("A") 27 assert.True(t, A) 28 B, _ := lessOrEqC("B") 29 assert.True(t, B) 30 C, _ := lessOrEqC("C") 31 assert.True(t, C) 32 D, _ := lessOrEqC("D") 33 assert.False(t, D) 34 } 35 36 func Test_gtThan(t *testing.T) { 37 gtC := more.Than("C") 38 A, _ := gtC("A") 39 assert.False(t, A) 40 B, _ := gtC("B") 41 assert.False(t, B) 42 C, _ := gtC("C") 43 assert.False(t, C) 44 D, _ := gtC("D") 45 assert.True(t, D) 46 E, _ := gtC("E") 47 assert.True(t, E) 48 } 49 50 func Test_gtOrEq(t *testing.T) { 51 gtOrEqC := more.OrEq("C") 52 A, _ := gtOrEqC("A") 53 assert.False(t, A) 54 B, _ := gtOrEqC("B") 55 assert.False(t, B) 56 C, _ := gtOrEqC("C") 57 assert.True(t, C) 58 D, _ := gtOrEqC("D") 59 assert.True(t, D) 60 E, _ := gtOrEqC("E") 61 assert.True(t, E) 62 } 63 64 func Test_OneOf(t *testing.T) { 65 oneOfACE := one.Of("A", "C", "E") 66 A, _ := oneOfACE("A") 67 assert.True(t, A) 68 B, _ := oneOfACE("B") 69 assert.False(t, B) 70 C, _ := oneOfACE("C") 71 assert.True(t, C) 72 D, _ := oneOfACE("D") 73 assert.False(t, D) 74 E, _ := oneOfACE("E") 75 assert.True(t, E) 76 }