...

Source file src/github.com/thoas/go-funk/short_if_test.go

Documentation: github.com/thoas/go-funk

     1  package funk
     2  
     3  import (
     4  	"testing"
     5  	"github.com/stretchr/testify/assert"
     6  )
     7  
     8  func TestShortIf(t *testing.T) {
     9  	is := assert.New(t)
    10  
    11  	r := ShortIf(10>5 , 10, 5)
    12  	is.Equal(r,10)
    13  
    14  	r = ShortIf(10.0 == 10 , "yes", "no")
    15  	is.Equal(r,"yes")
    16  
    17  	r = ShortIf('a'=='b',"equal chars","unequal chars")
    18  	is.Equal(r,"unequal chars")
    19  
    20  	r = ShortIf("abc"=="abc","Same string","Different strings")
    21  	is.Equal(r,"Same string")
    22  
    23  	type testStruct struct{}
    24  	a := testStruct{}
    25  	b := testStruct{}
    26  	r = ShortIf(a==b , &a, &b)
    27  	is.Equal(r,&b)
    28  
    29  }
    30  

View as plain text