Debian Codegraph @

execution/func_sum_test.go

raw symbols SCIP
1 package execution_test
2
3 import (
4 "github.com/tomwright/dasel/v3/model"
5 "testing"
6 )
7
8 func TestFuncSum(t *testing.T) {
9 t.Run("int", testCase{
10 s: `sum(1, 2, 3)`,
11 out: model.NewIntValue(6),
12 }.run)
13 t.Run("float", testCase{
14 s: `sum(1.1, 2.2, 3.3)`,
15 out: model.NewFloatValue(6.6),
16 }.run)
17 t.Run("negative int", testCase{
18 s: `sum(-1, -2, -3)`,
19 out: model.NewIntValue(-6),
20 }.run)
21 t.Run("negative float", testCase{
22 s: `sum(-1.1, -2.2, -3.3)`,
23 out: model.NewFloatValue(-6.6),
24 }.run)
25 t.Run("using int and float together returns float", testCase{
26 s: `sum(1, 1.1)`,
27 out: model.NewFloatValue(2.1),
28 }.run)
29 }