diff options
author | Jon Skeet <jonskeet@google.com> | 2016-02-15 11:58:01 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2016-02-15 11:58:01 +0000 |
commit | 9bdc848832b6f6e27ea4389a72c566ec43329114 (patch) | |
tree | f88ae024a5ecae5003e15f6184b15560c3c0a53b /csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs | |
parent | e35e24800fb8d694bdeea5fd63dc7d1b14d68723 (diff) | |
download | protobuf-9bdc848832b6f6e27ea4389a72c566ec43329114.tar.gz protobuf-9bdc848832b6f6e27ea4389a72c566ec43329114.tar.bz2 protobuf-9bdc848832b6f6e27ea4389a72c566ec43329114.zip |
Validate that end-group tags match their corresponding start-group tags
This detects:
- An end-group tag with the wrong field number (doesn't match the start-group field)
- An end-group tag with no preceding start-group tag
Fixes issue #688.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs index 14cc6d19..67069954 100644 --- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -679,21 +679,20 @@ namespace Google.Protobuf /// for details; we may want to change this.
/// </summary>
[Test]
- public void ExtraEndGroupSkipped()
+ public void ExtraEndGroupThrows()
{
var message = SampleMessages.CreateFullTestAllTypes();
var stream = new MemoryStream();
var output = new CodedOutputStream(stream);
- output.WriteTag(100, WireFormat.WireType.EndGroup);
output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32);
output.WriteFixed32(123);
+ output.WriteTag(100, WireFormat.WireType.EndGroup);
output.Flush();
stream.Position = 0;
- var parsed = TestAllTypes.Parser.ParseFrom(stream);
- Assert.AreEqual(new TestAllTypes { SingleFixed32 = 123 }, parsed);
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(stream));
}
[Test]
|