diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-09-08 14:16:21 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-09-08 16:59:43 +0200 |
commit | 0462c96a5a9da3e8adc78d96acd39575a8b46c40 (patch) | |
tree | bdcf3a56a54883ff9819afa2110231f0324acf63 /tpl/compare/compare_test.go | |
parent | 202510fdc92d52a20baeaa7edb1091f6882bd95f (diff) |
tpl/compare: Add cond (ternary) template func
Fixes #3860
Diffstat (limited to 'tpl/compare/compare_test.go')
-rw-r--r-- | tpl/compare/compare_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tpl/compare/compare_test.go b/tpl/compare/compare_test.go index 9adbcf574..c9bc2ffe9 100644 --- a/tpl/compare/compare_test.go +++ b/tpl/compare/compare_test.go @@ -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)) +} |