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

Function TestMemoryTrackingCalculationLimitExceeded

cel/memory_test.go:203–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func TestMemoryTrackingCalculationLimitExceeded(t *testing.T) {
204 env := testEnv(t, Variable("a", ListType(StringType)))
205 ast, iss := env.Compile(`a`)
206 if iss.Err() != nil {
207 t.Fatalf("env.Compile() failed: %v", iss.Err())
208 }
209 program, err := env.Program(ast,
210 MemoryTracking(
211 types.MemoryTrackerSizeCalculator(
212 types.NewSizeCalculator(types.SizeCalculatorMaxTraversal(2)))))
213 if err != nil {
214 t.Fatalf("env.Program() failed: %v", err)
215 }
216 _, details, err := program.Eval(map[string]any{"a": []string{"a", "b", "c", "d", "e"}})
217 if err != nil {
218 t.Fatalf("program.Eval() failed: %v", err)
219 }
220 if peak := details.PeakMemory(); peak == nil || *peak != math.MaxUint32 {
221 t.Errorf("EvalDetails.PeakMemory() got %v, wanted MaxUint32", peak)
222 }
223}

Callers

nothing calls this directly

Calls 11

NewSizeCalculatorFunction · 0.92
MemoryTrackingFunction · 0.85
ErrMethod · 0.80
ProgramMethod · 0.80
PeakMemoryMethod · 0.80
testEnvFunction · 0.70
VariableFunction · 0.70
CompileMethod · 0.65
EvalMethod · 0.65

Tested by

no test coverage detected