diff options
author | Jon Skeet <skeet@pobox.com> | 2015-08-08 07:24:57 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-08-08 07:24:57 +0100 |
commit | cac45313235bd11b08e0803453a2ec5a7d4b652a (patch) | |
tree | b513d3030e013c59fc2a2ef4df0be6a0509b5dc9 /csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs | |
parent | b76b76ba4f5152550fd334a6f3533d4db208f633 (diff) | |
parent | 6e16037c9933e175f62feb445ff8bd22d7727285 (diff) | |
download | protobuf-cac45313235bd11b08e0803453a2ec5a7d4b652a.tar.gz protobuf-cac45313235bd11b08e0803453a2ec5a7d4b652a.tar.bz2 protobuf-cac45313235bd11b08e0803453a2ec5a7d4b652a.zip |
Merge pull request #694 from jskeet/groups
Fix groups handling in C#
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs index d2a07057..fbc0ff07 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -322,5 +322,28 @@ namespace Google.Protobuf.WellKnownTypes // A normal implementation would have 0 now, as the explicit default would have been overwritten the 5. Assert.AreEqual(5, message.Int32Field); } + + [Test] + public void UnknownFieldInWrapper() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + var wrapperTag = WireFormat.MakeTag(TestWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited); + var unknownTag = WireFormat.MakeTag(15, WireFormat.WireType.Varint); + var valueTag = WireFormat.MakeTag(Int32Value.ValueFieldNumber, WireFormat.WireType.Varint); + + output.WriteTag(wrapperTag); + output.WriteLength(4); // unknownTag + value 5 + valueType + value 6, each 1 byte + output.WriteTag(unknownTag); + output.WriteInt32((int) valueTag); // Sneakily "pretend" it's a tag when it's really a value + output.WriteTag(valueTag); + output.WriteInt32(6); + + output.Flush(); + stream.Position = 0; + + var message = TestWellKnownTypes.Parser.ParseFrom(stream); + Assert.AreEqual(6, message.Int32Field); + } } } |