Add test for parsing using coded input

pull/7246/head
Sydney Acksman 5 years ago
parent ca123ec40e
commit d36d84c77b
  1. 13
      csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs

@ -376,5 +376,18 @@ namespace Google.Protobuf
TestGroupExtension extendable_parsed = TestGroupExtension.Parser.WithExtensionRegistry(new ExtensionRegistry() { TestNestedExtension.Extensions.OptionalGroupExtension }).ParseFrom(bytes);
Assert.AreEqual(message, extendable_parsed);
}
[Test]
public void RoundTrip_ParseUsingCodedInput()
{
var message = new TestAllExtensions();
message.SetExtension(UnittestExtensions.OptionalBoolExtension, true);
byte[] bytes = message.ToByteArray();
using (CodedInputStream input = new CodedInputStream(bytes))
{
var parsed = TestAllExtensions.Parser.WithExtensionRegistry(new ExtensionRegistry() { UnittestExtensions.OptionalBoolExtension }).ParseFrom(input);
Assert.AreEqual(message, parsed);
}
}
}
}

Loading…
Cancel
Save