(t *testing.T)
| 632 | } |
| 633 | |
| 634 | func TestAtof(t *testing.T) { |
| 635 | err := Init(nil) |
| 636 | require.NoError(t, err) |
| 637 | |
| 638 | tests := []struct { |
| 639 | name string |
| 640 | env map[string]any |
| 641 | code string |
| 642 | result float64 |
| 643 | }{ |
| 644 | { |
| 645 | name: "Atof() test: basic test", |
| 646 | env: map[string]any{ |
| 647 | "testFloat": "1.5", |
| 648 | }, |
| 649 | code: "Atof(testFloat)", |
| 650 | result: 1.5, |
| 651 | }, |
| 652 | { |
| 653 | name: "Atof() test: bad float", |
| 654 | env: map[string]any{ |
| 655 | "testFloat": "1aaa.5", |
| 656 | }, |
| 657 | code: "Atof(testFloat)", |
| 658 | result: 0.0, |
| 659 | }, |
| 660 | } |
| 661 | |
| 662 | for _, test := range tests { |
| 663 | program, err := expr.Compile(test.code, GetExprOptions(test.env)...) |
| 664 | require.NoError(t, err) |
| 665 | output, err := expr.Run(program, test.env) |
| 666 | require.NoError(t, err) |
| 667 | require.InDelta(t, test.result, output, 0.000001) |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | func TestUpper(t *testing.T) { |
| 672 | testStr := "test" |
nothing calls this directly
no test coverage detected
searching dependent graphs…