github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/break/op/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/op" 9 ) 10 11 func Test_Min(t *testing.T) { 12 assert.Equal(t, 5, op.Min(5, 5)) 13 assert.Equal(t, 5, op.Min(5, 6)) 14 assert.Equal(t, "A", op.Min("a", "A")) 15 } 16 17 func Test_Max(t *testing.T) { 18 assert.Equal(t, 5, op.Max(5, 5)) 19 assert.Equal(t, 6, op.Max(5, 6)) 20 assert.Equal(t, "a", op.Max("a", "A")) 21 } 22 23 func Test_IfElse(t *testing.T) { 24 assert.Equal(t, 5, op.IfElse(true, 5, 6)) 25 assert.Equal(t, 6, op.IfElse(false, 5, 6)) 26 } 27 28 func Test_IfElseDelay(t *testing.T) { 29 assert.Equal(t, 5, op.IfElse(true, func() int { return 5 }, func() int { return 6 })()) 30 assert.Equal(t, 6, op.IfElse(false, func() int { return 5 }, func() int { return 6 })()) 31 } 32 33 func Test_IfDoElse(t *testing.T) { 34 assert.Equal(t, 5, op.IfGetElse(true, func() int { return 5 }, func() int { return 6 })) 35 assert.Equal(t, 6, op.IfGetElse(false, func() int { return 5 }, func() int { return 6 })) 36 }