| 1 | package execution_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/tomwright/dasel/v3/model" |
| 7 | ) |
| 8 | |
| 9 | func TestFuncFloor(t *testing.T) { |
| 10 | t.Run("positive float", testCase{ |
| 11 | s: `floor(3.7)`, |
| 12 | out: model.NewIntValue(3), |
| 13 | }.run) |
| 14 | t.Run("negative float", testCase{ |
| 15 | s: `floor(-3.2)`, |
| 16 | out: model.NewIntValue(-4), |
| 17 | }.run) |
| 18 | t.Run("whole float", testCase{ |
| 19 | s: `floor(5.0)`, |
| 20 | out: model.NewIntValue(5), |
| 21 | }.run) |
| 22 | t.Run("int passthrough", testCase{ |
| 23 | s: `floor(5)`, |
| 24 | out: model.NewIntValue(5), |
| 25 | }.run) |
| 26 | t.Run("chained", testCase{ |
| 27 | s: `(3.7).floor()`, |
| 28 | out: model.NewIntValue(3), |
| 29 | }.run) |
| 30 | } |