Skip to content

Commit dfbfb23

Browse files
committed
Add tests for functions in functions.go.
1 parent 989da45 commit dfbfb23

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

numeric_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package sprig
22

33
import (
44
"fmt"
5-
"github.com/stretchr/testify/assert"
65
"strconv"
76
"testing"
7+
8+
"github.com/stretchr/testify/assert"
89
)
910

1011
func TestUntil(t *testing.T) {
@@ -249,6 +250,13 @@ func TestDivf(t *testing.T) {
249250
}
250251
}
251252

253+
func TestMod(t *testing.T) {
254+
tpl := `{{ mod 7 2 }}`
255+
if err := runt(tpl, `1`); err != nil {
256+
t.Error(err)
257+
}
258+
}
259+
252260
func TestMul(t *testing.T) {
253261
tpl := `{{ 1 | mul "2" 3 "4"}}`
254262
if err := runt(tpl, `24`); err != nil {

strings_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,17 @@ func TestPlural(t *testing.T) {
297297
t.Error(err)
298298
}
299299
}
300+
301+
func TestRepeat(t *testing.T) {
302+
tpl := `{{ "foo" | repeat 5 }}`
303+
if err := runt(tpl, "foofoofoofoofoo"); err != nil {
304+
t.Error(err)
305+
}
306+
}
307+
308+
func TestSplitList(t *testing.T) {
309+
tpl := `{{ splitList "$" "foo$bar$baz" }}`
310+
if err := runt(tpl, "[foo bar baz]"); err != nil {
311+
t.Error(err)
312+
}
313+
}

0 commit comments

Comments
 (0)