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

Function TestStructFieldNil

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

Source from the content-addressed store, hash-verified

459}
460
461func TestStructFieldNil(t *testing.T) {
462 fac := ast.NewExprFactory()
463 entry := fac.NewMapEntry(1,
464 fac.NewLiteral(2, types.String("hello")),
465 fac.NewLiteral(3, types.String("world")),
466 false)
467
468 // intentionally convert the map entry to the wrong type
469 field := entry.AsStructField()
470 if field.Name() != "" {
471 t.Errorf("field.FieldName() got %s, wanted ''", field.Name())
472 }
473 if field.Value().Kind() != ast.UnspecifiedExprKind {
474 t.Errorf("field.Value() got %v, wanted unspecified", field.Value())
475 }
476 if field.IsOptional() {
477 t.Errorf("field.IsOptional() got %v, wanted ''", field.IsOptional())
478 }
479}
480
481func TestRenumberIDs(t *testing.T) {
482 fac := ast.NewExprFactory()

Callers

nothing calls this directly

Calls 9

NewMapEntryMethod · 0.95
NewLiteralMethod · 0.95
NewExprFactoryFunction · 0.92
StringTypeAlias · 0.92
AsStructFieldMethod · 0.65
NameMethod · 0.65
KindMethod · 0.65
ValueMethod · 0.65
IsOptionalMethod · 0.65

Tested by

no test coverage detected