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

Function TestAttribute_StringRepresentation

interpreter/attributes_test.go:1483–1511  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1481}
1482
1483func TestAttribute_StringRepresentation(t *testing.T) {
1484 reg := newTestRegistry(t)
1485 cont := containers.DefaultContainer
1486 fac := NewAttributeFactory(cont, reg, reg)
1487
1488 abs := fac.AbsoluteAttribute(1, "a.b")
1489 maybe := fac.MaybeAttribute(2, "c")
1490 rel := fac.RelativeAttribute(3, NewConstValue(1, types.String("d")))
1491 cond := fac.ConditionalAttribute(4, NewConstValue(1, types.True), abs, maybe)
1492 trail := types.NewAttributeTrail("x")
1493
1494 tests := []struct {
1495 name string
1496 stringer fmt.Stringer
1497 }{
1498 {name: "absoluteAttribute", stringer: abs.(fmt.Stringer)},
1499 {name: "maybeAttribute", stringer: maybe.(fmt.Stringer)},
1500 {name: "relativeAttribute", stringer: rel.(fmt.Stringer)},
1501 {name: "conditionalAttribute", stringer: cond.(fmt.Stringer)},
1502 {name: "AttributeTrail", stringer: trail},
1503 }
1504 for _, tc := range tests {
1505 t.Run(tc.name, func(t *testing.T) {
1506 if str := tc.stringer.String(); str == "" {
1507 t.Errorf("%s.String() returned empty string", tc.name)
1508 }
1509 })
1510 }
1511}

Callers

nothing calls this directly

Calls 10

AbsoluteAttributeMethod · 0.95
MaybeAttributeMethod · 0.95
RelativeAttributeMethod · 0.95
ConditionalAttributeMethod · 0.95
StringTypeAlias · 0.92
NewAttributeTrailFunction · 0.92
NewAttributeFactoryFunction · 0.85
NewConstValueFunction · 0.85
newTestRegistryFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected