(t *testing.T)
| 689 | } |
| 690 | |
| 691 | func TestMathCosts(t *testing.T) { |
| 692 | tests := []struct { |
| 693 | name string |
| 694 | expr string |
| 695 | vars []cel.EnvOption |
| 696 | in map[string]any |
| 697 | hints map[string]uint64 |
| 698 | estimatedCost checker.CostEstimate |
| 699 | actualCost uint64 |
| 700 | version int |
| 701 | }{ |
| 702 | { |
| 703 | name: "math_greatest_list_v2", |
| 704 | expr: "math.greatest(x) == 5", |
| 705 | vars: []cel.EnvOption{ |
| 706 | cel.Variable("x", cel.ListType(cel.IntType)), |
| 707 | }, |
| 708 | in: map[string]any{ |
| 709 | "x": []int64{1, 2, 3, 4, 5}, |
| 710 | }, |
| 711 | hints: map[string]uint64{ |
| 712 | "x": 10, |
| 713 | }, |
| 714 | estimatedCost: checker.CostEstimate{Min: 3, Max: 3}, |
| 715 | actualCost: 3, |
| 716 | version: 2, |
| 717 | }, |
| 718 | { |
| 719 | name: "math_greatest_list_v3", |
| 720 | expr: "math.greatest(x) == 5", |
| 721 | vars: []cel.EnvOption{ |
| 722 | cel.Variable("x", cel.ListType(cel.IntType)), |
| 723 | }, |
| 724 | in: map[string]any{ |
| 725 | "x": []int64{1, 2, 3, 4, 5}, |
| 726 | }, |
| 727 | hints: map[string]uint64{ |
| 728 | "x": 10, |
| 729 | }, |
| 730 | estimatedCost: checker.CostEstimate{Min: 3, Max: 13}, |
| 731 | actualCost: 8, |
| 732 | version: 3, |
| 733 | }, |
| 734 | { |
| 735 | name: "math_least_list_v2", |
| 736 | expr: "math.least(x) == -3.0", |
| 737 | vars: []cel.EnvOption{ |
| 738 | cel.Variable("x", cel.ListType(cel.DoubleType)), |
| 739 | }, |
| 740 | in: map[string]any{ |
| 741 | "x": []float64{-1.0, -2.0, -3.0}, |
| 742 | }, |
| 743 | hints: map[string]uint64{ |
| 744 | "x": 100, |
| 745 | }, |
| 746 | estimatedCost: checker.CostEstimate{Min: 3, Max: 3}, |
| 747 | actualCost: 3, |
| 748 | version: 2, |
nothing calls this directly
no test coverage detected