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