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

Function TestList

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

Source from the content-addressed store, hash-verified

282}
283
284func TestList(t *testing.T) {
285 fac := ast.NewExprFactory()
286 expr := fac.NewList(20, []ast.Expr{fac.NewLiteral(21, types.OptionalOf(types.True))}, []int32{0})
287 list := expr.AsList()
288 if list.Size() != 1 {
289 t.Errorf("list.Size() got %s, wanted 'a'", expr.AsIdent())
290 }
291 if list.Elements()[0].Kind() != ast.LiteralKind {
292 t.Errorf("list.Elements()[0] got %v, wanted true", list.Elements()[0])
293 }
294 if list.OptionalIndices()[0] != 0 {
295 t.Errorf("list.OptionalIndices()[0] got %d, wanted 0", list.OptionalIndices()[0])
296 }
297 expr.RenumberIDs(testIDGen(50))
298 if expr.ID() != 51 {
299 t.Errorf("expr.ID() got %d, wanted 51", expr.ID())
300 }
301 if list.Elements()[0].ID() != 52 {
302 t.Errorf("list.Elements()[0].ID() got %d, wanted 52", list.Elements()[0].ID())
303 }
304}
305
306func TestListNil(t *testing.T) {
307 expr := nilTestExpr(t)

Callers

nothing calls this directly

Calls 13

NewListMethod · 0.95
NewLiteralMethod · 0.95
NewExprFactoryFunction · 0.92
OptionalOfFunction · 0.92
testIDGenFunction · 0.85
AsListMethod · 0.65
SizeMethod · 0.65
AsIdentMethod · 0.65
KindMethod · 0.65
ElementsMethod · 0.65
OptionalIndicesMethod · 0.65
RenumberIDsMethod · 0.65

Tested by

no test coverage detected