@@ -55,6 +55,7 @@ func TestFields(t *testing.T) {
55
55
{"desc_test_proto3_optional.proto" , files },
56
56
{"all_default_features.proto" , editionFiles },
57
57
{"features_with_overrides.proto" , editionFiles },
58
+ {"file_default_delimited.proto" , editionFiles },
58
59
}
59
60
for _ , testCase := range testCases {
60
61
testCase := testCase // must not capture loop variable below, for thread safety
@@ -150,7 +151,13 @@ func checkAttributesInFields(t *testing.T, exp, actual protoreflect.ExtensionDes
150
151
}
151
152
assert .Equal (t , expFld .Number (), actFld .Number (), "%s: field number at index %d (%s)" , where , i , expFld .Name ())
152
153
assert .Equal (t , expFld .Cardinality (), actFld .Cardinality (), "%s: field cardinality at index %d (%s)" , where , i , expFld .Name ())
153
- assert .Equal (t , expFld .Kind (), actFld .Kind (), "%s: field kind at index %d (%s)" , where , i , expFld .Name ())
154
+ if isMapOrMapEntryMessageValue (actFld ) {
155
+ // TODO: Remove this branch and just use the check below once the protobuf-go runtime fixes
156
+ // https://github.com/golang/protobuf/issues/1615
157
+ assert .Equal (t , protoreflect .MessageKind , actFld .Kind (), "%s: field kind at index %d (%s)" , where , i , expFld .Name ())
158
+ } else {
159
+ assert .Equal (t , expFld .Kind (), actFld .Kind (), "%s: field kind at index %d (%s)" , where , i , expFld .Name ())
160
+ }
154
161
assert .Equal (t , expFld .IsList (), actFld .IsList (), "%s: field is list at index %d (%s)" , where , i , expFld .Name ())
155
162
assert .Equal (t , expFld .IsMap (), actFld .IsMap (), "%s: field is map at index %d (%s)" , where , i , expFld .Name ())
156
163
assert .Equal (t , expFld .JSONName (), actFld .JSONName (), "%s: field json name at index %d (%s)" , where , i , expFld .Name ())
@@ -241,3 +248,14 @@ func checkAttributesInEnums(t *testing.T, exp, actual protoreflect.EnumDescripto
241
248
assert .Equal (t , expEnum .IsClosed (), actEnum .IsClosed (), "%s: enum is closed at index %d (%s)" , where , i , expEnum .Name ())
242
249
}
243
250
}
251
+
252
+ func isMapOrMapEntryMessageValue (field protoreflect.FieldDescriptor ) bool {
253
+ if field .IsMap () {
254
+ return true // map field
255
+ }
256
+ if field .Message () == nil {
257
+ return false // not a message field
258
+ }
259
+ parent , ok := field .Parent ().(protoreflect.MessageDescriptor )
260
+ return ok && parent .IsMapEntry ()
261
+ }
0 commit comments