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

Function TestMathStaticErrors

ext/math_test.go:237–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

235}
236
237func TestMathStaticErrors(t *testing.T) {
238 mathTests := []struct {
239 expr string
240 err string
241 }{
242 // Tests for math.least
243 {
244 expr: "math.least()",
245 err: "math.least() requires at least one argument",
246 },
247 {
248 expr: "math.least('hello')",
249 err: "math.least() invalid single argument value",
250 },
251 {
252 expr: "math.least({})",
253 err: "math.least() invalid single argument value",
254 },
255 {
256 expr: "math.least(1, true)",
257 err: "math.least() simple literal arguments must be numeric",
258 },
259 {
260 expr: "math.least(1, 2, true)",
261 err: "math.least() simple literal arguments must be numeric",
262 },
263
264 // Tests for math.greatest
265 {
266 expr: "math.greatest()",
267 err: "math.greatest() requires at least one argument",
268 },
269 {
270 expr: "math.greatest(true)",
271 err: "math.greatest() invalid single argument value",
272 },
273 {
274 expr: "math.greatest([])",
275 err: "math.greatest() invalid single argument value",
276 },
277 {
278 expr: "math.greatest([1, true])",
279 err: "math.greatest() invalid single argument value",
280 },
281 {
282 expr: "math.greatest(1, true)",
283 err: "math.greatest() simple literal arguments must be numeric",
284 },
285 {
286 expr: "math.greatest(1, 2, true)",
287 err: "math.greatest() simple literal arguments must be numeric",
288 },
289 }
290
291 env := testMathEnv(t)
292 for i, tst := range mathTests {
293 tc := tst
294 t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

testMathEnvFunction · 0.85
ErrMethod · 0.80
CompileMethod · 0.65
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected