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

Function TestSelect

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

Source from the content-addressed store, hash-verified

384}
385
386func TestSelect(t *testing.T) {
387 fac := ast.NewExprFactory()
388 expr := fac.NewSelect(2, fac.NewIdent(1, "operand"), "field")
389 sel := expr.AsSelect()
390 if sel.FieldName() != "field" {
391 t.Errorf("sel.FieldName() got %s, wanted 'field'", sel.FieldName())
392 }
393 if sel.Operand().AsIdent() != "operand" {
394 t.Errorf("sel.Operand().AsIdent() got %s, wanted 'operand'", sel.Operand().AsIdent())
395 }
396 expr.RenumberIDs(testIDGen(20))
397 if sel.Operand().ID() != 22 {
398 t.Errorf("Operand().ID() got %d, wanted 22", sel.Operand().ID())
399 }
400}
401
402func TestSelectNil(t *testing.T) {
403 expr := nilTestExpr(t)

Callers

nothing calls this directly

Calls 10

NewSelectMethod · 0.95
NewIdentMethod · 0.95
NewExprFactoryFunction · 0.92
testIDGenFunction · 0.85
AsSelectMethod · 0.65
FieldNameMethod · 0.65
AsIdentMethod · 0.65
OperandMethod · 0.65
RenumberIDsMethod · 0.65
IDMethod · 0.65

Tested by

no test coverage detected