aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-08-05 11:23:38 +0100
committerJon Skeet <jonskeet@google.com>2015-08-05 11:23:38 +0100
commitff334a60eb2e74722867dd41b78d7c8c90bc8d0c (patch)
tree6aca2c954c9ea56bff5690d6ee7e5423a2ac13d8 /csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
parent607940321c8ceeb80ec1099d94add8eef86825e5 (diff)
downloadprotobuf-ff334a60eb2e74722867dd41b78d7c8c90bc8d0c.tar.gz
protobuf-ff334a60eb2e74722867dd41b78d7c8c90bc8d0c.tar.bz2
protobuf-ff334a60eb2e74722867dd41b78d7c8c90bc8d0c.zip
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.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs')
-rw-r--r--csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs19
1 files changed, 12 insertions, 7 deletions
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);