(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 cost.CostEstimate |
| 699 | // estimatedCostV0 is the estimate under cost.ModelVersion0, set only where the revision moved it. |
| 700 | estimatedCostV0 *cost.CostEstimate |
| 701 | actualCost uint64 |
| 702 | version int |
| 703 | }{ |
| 704 | { |
| 705 | name: "math_greatest_list_v2", |
| 706 | expr: "math.greatest(x) == 5", |
| 707 | vars: []cel.EnvOption{ |
| 708 | cel.Variable("x", cel.ListType(cel.IntType)), |
| 709 | }, |
| 710 | in: map[string]any{ |
| 711 | "x": []int64{1, 2, 3, 4, 5}, |
| 712 | }, |
| 713 | hints: map[string]uint64{ |
| 714 | "x": 10, |
| 715 | }, |
| 716 | estimatedCost: cost.FixedCostEstimate(3), |
| 717 | actualCost: 3, |
| 718 | version: 2, |
| 719 | }, |
| 720 | { |
| 721 | name: "math_greatest_list_v3", |
| 722 | expr: "math.greatest(x) == 5", |
| 723 | vars: []cel.EnvOption{ |
| 724 | cel.Variable("x", cel.ListType(cel.IntType)), |
| 725 | }, |
| 726 | in: map[string]any{ |
| 727 | "x": []int64{1, 2, 3, 4, 5}, |
| 728 | }, |
| 729 | hints: map[string]uint64{ |
| 730 | "x": 10, |
| 731 | }, |
| 732 | estimatedCost: cost.RangedCostEstimate(3, 13), |
| 733 | actualCost: 8, |
| 734 | version: 3, |
| 735 | }, |
| 736 | { |
| 737 | name: "math_least_list_v2", |
| 738 | expr: "math.least(x) == -3.0", |
| 739 | vars: []cel.EnvOption{ |
| 740 | cel.Variable("x", cel.ListType(cel.DoubleType)), |
| 741 | }, |
| 742 | in: map[string]any{ |
| 743 | "x": []float64{-1.0, -2.0, -3.0}, |
| 744 | }, |
| 745 | hints: map[string]uint64{ |
| 746 | "x": 100, |
| 747 | }, |
| 748 | estimatedCost: cost.FixedCostEstimate(3), |
nothing calls this directly
no test coverage detected