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

Function TestNativeStructWithMultipleSameFieldNames

ext/native_test.go:931–952  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

929}
930
931func TestNativeStructWithMultipleSameFieldNames(t *testing.T) {
932 tagHandler := func(f reflect.StructField) string {
933 tag, found := f.Tag.Lookup("cel")
934 if found {
935 splits := strings.Split(tag, ",")
936 if len(splits) > 0 {
937 return splits[0]
938 }
939 }
940 return f.Name
941 }
942 _, err := types.NewNativeType(
943 reflect.TypeFor[TestStructWithMultipleSameNames](),
944 types.ParseStructField(tagHandler),
945 )
946 if err == nil {
947 t.Fatal("NewNativeType() did not fail as expected")
948 }
949 if !strings.Contains(err.Error(), "field name already exists") {
950 t.Fatalf("NewNativeType() expected duplicated field name error, but got: %v", err)
951 }
952}
953
954func TestNativeStructEmbedded(t *testing.T) {
955 var nativeTests = []struct {

Callers

nothing calls this directly

Calls 4

NewNativeTypeFunction · 0.92
ParseStructFieldFunction · 0.92
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected