From ff334a60eb2e74722867dd41b78d7c8c90bc8d0c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 5 Aug 2015 11:23:38 +0100 Subject: Change ReadTag and PeekTag to just use 0 as a return value for "end of stream", rather than using an awkward out parameter. This simplifies quite a lot of code. Generated code in next commit. --- .../src/Google.Protobuf.Test/CodedOutputStreamTest.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs') diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs index af329174..c1bf7bd6 100644 --- a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -335,15 +335,16 @@ namespace Google.Protobuf // Now test Input stream: { CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50]); - uint tag; Assert.AreEqual(0, cin.Position); // Field 1: - Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 1); + uint tag = cin.ReadTag(); + Assert.AreEqual(1, tag >> 3); Assert.AreEqual(1, cin.Position); Assert.AreEqual(500, cin.ReadInt32()); Assert.AreEqual(3, cin.Position); //Field 2: - Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 2); + tag = cin.ReadTag(); + Assert.AreEqual(2, tag >> 3); Assert.AreEqual(4, cin.Position); int childlen = cin.ReadLength(); Assert.AreEqual(120, childlen); @@ -353,19 +354,22 @@ namespace Google.Protobuf // Now we are reading child message { // Field 11: numeric value: 500 - Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 11); + tag = cin.ReadTag(); + Assert.AreEqual(11, tag >> 3); Assert.AreEqual(6, cin.Position); Assert.AreEqual(500, cin.ReadInt32()); Assert.AreEqual(8, cin.Position); //Field 12: length delimited 120 bytes - Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 12); + tag = cin.ReadTag(); + Assert.AreEqual(12, tag >> 3); Assert.AreEqual(9, cin.Position); ByteString bstr = cin.ReadBytes(); Assert.AreEqual(110, bstr.Length); Assert.AreEqual((byte) 109, bstr[109]); Assert.AreEqual(120, cin.Position); // Field 13: fixed numeric value: 501 - Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 13); + tag = cin.ReadTag(); + Assert.AreEqual(13, tag >> 3); // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit Assert.AreEqual(121, cin.Position); Assert.AreEqual(501, cin.ReadSFixed32()); @@ -375,7 +379,8 @@ namespace Google.Protobuf cin.PopLimit(oldlimit); Assert.AreEqual(125, cin.Position); // Field 3: fixed numeric value: 501 - Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 3); + tag = cin.ReadTag(); + Assert.AreEqual(3, tag >> 3); Assert.AreEqual(126, cin.Position); Assert.AreEqual(501, cin.ReadSFixed32()); Assert.AreEqual(130, cin.Position); -- cgit v1.2.3