| 1 | package execution_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/tomwright/dasel/v3/model" |
| 7 | ) |
| 8 | |
| 9 | func TestFuncAvg(t *testing.T) { |
| 10 | t.Run("ints", testCase{ |
| 11 | s: `avg(2, 4, 6)`, |
| 12 | out: model.NewFloatValue(4.0), |
| 13 | }.run) |
| 14 | t.Run("floats", testCase{ |
| 15 | s: `avg(1.5, 2.5, 3.0)`, |
| 16 | out: model.NewFloatValue(7.0 / 3.0), |
| 17 | }.run) |
| 18 | t.Run("mixed", testCase{ |
| 19 | s: `avg(1, 2.0, 3)`, |
| 20 | out: model.NewFloatValue(2.0), |
| 21 | }.run) |
| 22 | t.Run("single value", testCase{ |
| 23 | s: `avg(5)`, |
| 24 | out: model.NewFloatValue(5.0), |
| 25 | }.run) |
| 26 | } |