@@ -25,7 +25,6 @@ import (
2525 "github.com/google/cel-go/common/stdlib"
2626 "github.com/google/cel-go/common/types"
2727 "github.com/google/cel-go/parser"
28-
2928 proto3pb "github.com/google/cel-go/test/proto3pb"
3029)
3130
@@ -261,13 +260,29 @@ func TestCost(t *testing.T) {
261260 expr : `string(input)` ,
262261 wanted : CostEstimate {Min : 1 , Max : 51 },
263262 },
263+ {
264+ name : "bytes to string conversion equality" ,
265+ vars : []* decls.VariableDecl {decls .NewVariable ("input" , types .BytesType )},
266+ hints : map [string ]int64 {"input" : 500 },
267+ // equality check ensures that the resultSize calculation is included in cost
268+ expr : `string(input) == string(input)` ,
269+ wanted : CostEstimate {Min : 3 , Max : 152 },
270+ },
264271 {
265272 name : "string to bytes conversion" ,
266273 vars : []* decls.VariableDecl {decls .NewVariable ("input" , types .StringType )},
267274 hints : map [string ]int64 {"input" : 500 },
268275 expr : `bytes(input)` ,
269276 wanted : CostEstimate {Min : 1 , Max : 51 },
270277 },
278+ {
279+ name : "string to bytes conversion equality" ,
280+ vars : []* decls.VariableDecl {decls .NewVariable ("input" , types .StringType )},
281+ hints : map [string ]int64 {"input" : 500 },
282+ // equality check ensures that the resultSize calculation is included in cost
283+ expr : `bytes(input) == bytes(input)` ,
284+ wanted : CostEstimate {Min : 3 , Max : 302 },
285+ },
271286 {
272287 name : "int to string conversion" ,
273288 expr : `string(1)` ,
0 commit comments