Skip to content

Commit 6e393fd

Browse files
Make the Proto2/Proto3 Defaults test check be non-exhaustive.
Since adding a new feature for a new Edition involves having a value set for Proto2/Proto3 which does not change the semantics of those files, the current test becomes a change detector test against new features being added. PiperOrigin-RevId: 714851850
1 parent c8ad774 commit 6e393fd

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

Diff for: csharp/src/Google.Protobuf.Test/Reflection/FeatureSetDescriptorTest.cs

+18-20
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,31 @@ public class FeatureSetDescriptorTest
2222
[Test]
2323
public void Proto2Defaults()
2424
{
25-
var expectedDefaults = new FeatureSet
26-
{
27-
EnumType = EnumType.Closed,
28-
FieldPresence = FieldPresence.Explicit,
29-
JsonFormat = JsonFormat.LegacyBestEffort,
30-
MessageEncoding = MessageEncoding.LengthPrefixed,
31-
RepeatedFieldEncoding = RepeatedFieldEncoding.Expanded,
32-
Utf8Validation = Utf8Validation.None,
33-
};
25+
// Note: additional fixed features may be added in future Editions (features which
26+
// have a value set to match preexisting proto2 behavior), so this is not an exhaustive
27+
// list of all proto2 defaults.
3428
var actualDefaults = FeatureSetDescriptor.GetEditionDefaults(Edition.Proto2).Proto;
35-
Assert.AreEqual(expectedDefaults, actualDefaults);
29+
Assert.AreEqual(EnumType.Closed, actualDefaults.EnumType);
30+
Assert.AreEqual(FieldPresence.Explicit, actualDefaults.FieldPresence);
31+
Assert.AreEqual(JsonFormat.LegacyBestEffort, actualDefaults.JsonFormat);
32+
Assert.AreEqual(MessageEncoding.LengthPrefixed, actualDefaults.MessageEncoding);
33+
Assert.AreEqual(RepeatedFieldEncoding.Expanded, actualDefaults.RepeatedFieldEncoding);
34+
Assert.AreEqual(Utf8Validation.None, actualDefaults.Utf8Validation);
3635
}
3736

3837
[Test]
3938
public void Proto3Defaults()
4039
{
41-
var expectedDefaults = new FeatureSet
42-
{
43-
EnumType = EnumType.Open,
44-
FieldPresence = FieldPresence.Implicit,
45-
JsonFormat = JsonFormat.Allow,
46-
MessageEncoding = MessageEncoding.LengthPrefixed,
47-
RepeatedFieldEncoding = RepeatedFieldEncoding.Packed,
48-
Utf8Validation = Utf8Validation.Verify,
49-
};
40+
// Note: additional fixed features may be added in future Editions (features which
41+
// have a value set to match preexisting proto2 behavior), so this is not an exhaustive
42+
// list of all proto2 defaults.
5043
var actualDefaults = FeatureSetDescriptor.GetEditionDefaults(Edition.Proto3).Proto;
51-
Assert.AreEqual(expectedDefaults, actualDefaults);
44+
Assert.AreEqual(EnumType.Open, actualDefaults.EnumType);
45+
Assert.AreEqual(FieldPresence.Implicit, actualDefaults.FieldPresence);
46+
Assert.AreEqual(JsonFormat.Allow, actualDefaults.JsonFormat);
47+
Assert.AreEqual(MessageEncoding.LengthPrefixed, actualDefaults.MessageEncoding);
48+
Assert.AreEqual(RepeatedFieldEncoding.Packed, actualDefaults.RepeatedFieldEncoding);
49+
Assert.AreEqual(Utf8Validation.Verify, actualDefaults.Utf8Validation);
5250
}
5351

5452
[Test]

0 commit comments

Comments
 (0)