From 9bdc848832b6f6e27ea4389a72c566ec43329114 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Mon, 15 Feb 2016 11:58:01 +0000 Subject: 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. --- csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs') 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. /// [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(() => TestAllTypes.Parser.ParseFrom(stream)); } [Test] -- cgit v1.2.3