strip-beats/utils/utils_tern_test.go

24 lines
389 B
Go
Raw Permalink Normal View History

2023-10-29 11:58:00 -05:00
package utils
import (
"testing"
2023-10-31 15:41:24 -05:00
"github.com/stretchr/testify/assert"
2023-10-29 11:58:00 -05:00
)
func TestTern(t *testing.T) {
2023-10-31 15:41:24 -05:00
assert.Equal(t, Tern(true, 5, 2), 5)
assert.Equal(t, Tern(false, 5, 2), 2)
2023-10-29 11:58:00 -05:00
}
func TestTernCall(t *testing.T) {
five := func() int {
return 5
}
two := func() int {
return 2
}
2023-10-31 15:41:24 -05:00
assert.Equal(t, TernCall(true, five, two), 5)
assert.Equal(t, TernCall(false, five, two), 2)
2023-10-29 11:58:00 -05:00
}