You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found and fixed a bug in FieldDescriptor.Cardinality implementation (#270)
Updates the descriptor implementation tests to check a few other
attributes, which uncovered a bug in the `Cardinality` method, which
should report "required" for editions fields where
`features.field_presence == LEGACY_REQUIRED`.
Copy file name to clipboardExpand all lines: linker/descriptors_ext_test.go
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -148,11 +148,16 @@ func checkAttributesInFields(t *testing.T, exp, actual protoreflect.ExtensionDes
148
148
if!assert.Equal(t, expFld.Name(), actFld.Name(), "%s: field name at index %d", where, i) {
149
149
continue
150
150
}
151
+
assert.Equal(t, expFld.Number(), actFld.Number(), "%s: field number at index %d (%s)", where, i, expFld.Name())
152
+
assert.Equal(t, expFld.Cardinality(), actFld.Cardinality(), "%s: field cardinality at index %d (%s)", where, i, expFld.Name())
151
153
assert.Equal(t, expFld.Kind(), actFld.Kind(), "%s: field kind at index %d (%s)", where, i, expFld.Name())
152
154
assert.Equal(t, expFld.IsList(), actFld.IsList(), "%s: field is list at index %d (%s)", where, i, expFld.Name())
153
155
assert.Equal(t, expFld.IsMap(), actFld.IsMap(), "%s: field is map at index %d (%s)", where, i, expFld.Name())
154
156
assert.Equal(t, expFld.JSONName(), actFld.JSONName(), "%s: field json name at index %d (%s)", where, i, expFld.Name())
155
157
assert.Equal(t, expFld.HasJSONName(), actFld.HasJSONName(), "%s: field has json name at index %d (%s)", where, i, expFld.Name())
158
+
assert.Equal(t, expFld.IsExtension(), actFld.IsExtension(), "%s: field is extension at index %d (%s)", where, i, expFld.Name())
159
+
assert.Equal(t, expFld.IsPacked(), actFld.IsPacked(), "%s: field is packed at index %d (%s)", where, i, expFld.Name())
160
+
assert.Equal(t, expFld.ContainingOneof() ==nil, actFld.ContainingOneof() ==nil, "%s: field containing oneof at index %d (%s)", where, i, expFld.Name())
0 commit comments