tpl/compare: Add cond (ternary) template func

Fixes #3860
This commit is contained in:
Bjørn Erik Pedersen 2017-09-08 14:16:21 +02:00
parent 202510fdc9
commit 0462c96a5a
3 changed files with 25 additions and 0 deletions

View file

@ -221,3 +221,12 @@ func TestTimeUnix(t *testing.T) {
toTimeUnix(iv)
}(t)
}
func TestConditional(t *testing.T) {
assert := require.New(t)
n := New()
a, b := "a", "b"
assert.Equal(a, n.Conditional(true, a, b))
assert.Equal(b, n.Conditional(false, a, b))
}