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

Function TestMapEntryNil

common/ast/expr_test.go:368–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

366}
367
368func TestMapEntryNil(t *testing.T) {
369 fac := ast.NewExprFactory()
370 field := fac.NewStructField(1,
371 "hello", fac.NewLiteral(3, types.String("world")), false)
372
373 // intentionally convert the struct field to the wrong type
374 entry := field.AsMapEntry()
375 if entry.Key().Kind() != ast.UnspecifiedExprKind {
376 t.Errorf("entry.Key() got %s, wanted ''", entry.Key())
377 }
378 if entry.Value().Kind() != ast.UnspecifiedExprKind {
379 t.Errorf("entry.Value() got %v, wanted unspecified", entry.Value())
380 }
381 if entry.IsOptional() {
382 t.Errorf("entry.IsOptional() got %v, wanted ''", entry.IsOptional())
383 }
384}
385
386func TestSelect(t *testing.T) {
387 fac := ast.NewExprFactory()

Callers

nothing calls this directly

Calls 9

NewStructFieldMethod · 0.95
NewLiteralMethod · 0.95
NewExprFactoryFunction · 0.92
StringTypeAlias · 0.92
AsMapEntryMethod · 0.65
KindMethod · 0.65
KeyMethod · 0.65
ValueMethod · 0.65
IsOptionalMethod · 0.65

Tested by

no test coverage detected