github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/expr/get/test/get_test.go (about)

     1  package test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/m4gshm/gollections/expr/get"
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  var (
    11  	getOne = func() int { return 1 }
    12  )
    13  
    14  func Test_GetIfElse(t *testing.T) {
    15  	result := get.If(true, getOne).Else(2)
    16  	assert.Equal(t, 1, result)
    17  
    18  	result = get.If(false, getOne).Else(2)
    19  	assert.Equal(t, 2, result)
    20  }