MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestNetworkCost

Function TestNetworkCost

ext/network_test.go:737–905  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

735}
736
737func 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),

Callers

nothing calls this directly

Calls 4

FixedCostEstimateFunction · 0.92
RangedCostEstimateFunction · 0.92
testCostFunction · 0.85
costV0Function · 0.70

Tested by

no test coverage detected