Add unit tests.

This commit is contained in:
Kermit Alexander II 2022-08-22 17:01:57 +00:00
parent 4a703d6cbc
commit 6042d781f5

View File

@ -1593,6 +1593,27 @@ func TestCostEstimation(t *testing.T) {
setMaxElements: 10,
expectedSetCost: 6,
},
{
name: "check cost of size call",
schemaGenerator: genMapWithRule("integer", "oldSelf.size() == self.size()"),
expectedCalcCost: 5,
setMaxElements: 10,
expectedSetCost: 5,
},
{
name: "check cost of timestamp comparison",
schemaGenerator: genMapWithRule("date-time", `self["a"] == self["b"]`),
expectedCalcCost: 8,
setMaxElements: 7,
expectedSetCost: 8,
},
{
name: "check cost of duration comparison",
schemaGenerator: genMapWithRule("duration", `self["c"] == self["d"]`),
expectedCalcCost: 8,
setMaxElements: 42,
expectedSetCost: 8,
},
}
for _, testCase := range cases {
t.Run(testCase.name, func(t *testing.T) {