diff options
Diffstat (limited to 'src/ProtocolBuffers.Test')
-rw-r--r-- | src/ProtocolBuffers.Test/GeneratedMessageTest.cs | 10 | ||||
-rw-r--r-- | src/ProtocolBuffers.Test/ReflectionTester.cs | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 5fb4f4db..b04fb399 100644 --- a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -265,6 +265,16 @@ namespace Google.ProtocolBuffers }
[TestMethod]
+ public void ReflectionClear()
+ {
+ TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
+ reflectionTester.SetAllFieldsViaReflection(builder);
+ reflectionTester.ClearAllFieldsViaReflection(builder);
+ TestAllTypes message = builder.Build();
+ TestUtil.AssertClear(message);
+ }
+
+ [TestMethod]
public void ReflectionSettersRejectNull()
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
diff --git a/src/ProtocolBuffers.Test/ReflectionTester.cs b/src/ProtocolBuffers.Test/ReflectionTester.cs index 9565a167..2120ff84 100644 --- a/src/ProtocolBuffers.Test/ReflectionTester.cs +++ b/src/ProtocolBuffers.Test/ReflectionTester.cs @@ -384,6 +384,18 @@ namespace Google.ProtocolBuffers message[f("default_cord")] = "425";
}
+ /// <summary>
+ /// Clears every field of the message, using the reflection interface.
+ /// </summary>
+ /// <param name="message"></param>
+ internal void ClearAllFieldsViaReflection(IBuilder message)
+ {
+ foreach (FieldDescriptor field in message.AllFields.Keys)
+ {
+ message.WeakClearField(field);
+ }
+ }
+
// -------------------------------------------------------------------
/// <summary>
|