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

Function TestMathStaticErrors

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

Source from the content-addressed store, hash-verified

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