(t *testing.T)
| 735 | } |
| 736 | |
| 737 | func TestNetworkCost(t *testing.T) { |
| 738 | tests := []struct { |
| 739 | name string |
| 740 | expr string |
| 741 | estimatedCost cost.CostEstimate |
| 742 | // estimatedCostV0 is the estimate under cost.ModelVersion0, set only where the revision moved |
| 743 | // it. |
| 744 | estimatedCostV0 *cost.CostEstimate |
| 745 | runtimeCost uint64 |
| 746 | }{ |
| 747 | { |
| 748 | name: "ip parse", |
| 749 | expr: "ip('192.168.0.1')", |
| 750 | estimatedCost: cost.FixedCostEstimate(2), |
| 751 | runtimeCost: 2, |
| 752 | }, |
| 753 | { |
| 754 | name: "isIP parse", |
| 755 | expr: "isIP('192.168.0.1')", |
| 756 | estimatedCost: cost.FixedCostEstimate(2), |
| 757 | runtimeCost: 2, |
| 758 | }, |
| 759 | { |
| 760 | name: "cidr parse", |
| 761 | expr: "cidr('192.168.0.0/16')", |
| 762 | estimatedCost: cost.FixedCostEstimate(2), |
| 763 | runtimeCost: 2, |
| 764 | }, |
| 765 | { |
| 766 | name: "isCIDR parse", |
| 767 | expr: "isCIDR('192.168.0.0/16')", |
| 768 | estimatedCost: cost.FixedCostEstimate(2), |
| 769 | runtimeCost: 2, |
| 770 | }, |
| 771 | { |
| 772 | name: "ip.isCanonical", |
| 773 | expr: "ip.isCanonical('192.168.0.1')", |
| 774 | estimatedCost: cost.FixedCostEstimate(3), |
| 775 | runtimeCost: 3, |
| 776 | }, |
| 777 | { |
| 778 | name: "cidr containsIP ip", |
| 779 | expr: "cidr('192.168.0.0/16').containsIP(ip('192.169.0.1'))", |
| 780 | estimatedCost: cost.RangedCostEstimate(5, 8), |
| 781 | runtimeCost: 5, |
| 782 | }, |
| 783 | { |
| 784 | name: "cidr containsIP string", |
| 785 | expr: "cidr('192.168.0.0/16').containsIP('192.0.0.1')", |
| 786 | estimatedCost: cost.RangedCostEstimate(3, 7), |
| 787 | estimatedCostV0: costV0(4, 7), |
| 788 | runtimeCost: 4, |
| 789 | }, |
| 790 | { |
| 791 | name: "cidr containsCIDR cidr", |
| 792 | expr: "cidr('192.168.0.0/16').containsCIDR(cidr('192.0.0.0/30'))", |
| 793 | estimatedCost: cost.RangedCostEstimate(5, 11), |
| 794 | estimatedCostV0: costV0(7, 11), |
nothing calls this directly
no test coverage detected