diff options
author | Jon Skeet <jonskeet@google.com> | 2017-06-12 07:04:22 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2017-07-04 06:42:45 +0100 |
commit | cdd524a0bdfc16853271cca7b8fa95577b75085d (patch) | |
tree | bb272f4a20d191758b11c2f33eb82634728dd392 /csharp/src/Google.Protobuf.Test | |
parent | 62d7fe569717b6da39401a94b22adf73466e1f2d (diff) | |
download | protobuf-cdd524a0bdfc16853271cca7b8fa95577b75085d.tar.gz protobuf-cdd524a0bdfc16853271cca7b8fa95577b75085d.tar.bz2 protobuf-cdd524a0bdfc16853271cca7b8fa95577b75085d.zip |
Ensure leaveOpen is true when writing to a buffer
Note that the compatibility tests have had to cahnge as well, to
cope with internal changes. (The test project has access to
internals in the main project.)
Fixes #3209.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs | 9 | ||||
-rw-r--r-- | csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs index c0a9ffd1..e719d2a0 100644 --- a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs @@ -403,7 +403,7 @@ namespace Google.Protobuf output.Flush();
ms.Position = 0;
- CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0);
+ CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0, false);
uint tag = input.ReadTag();
Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag));
@@ -594,5 +594,12 @@ namespace Google.Protobuf }
Assert.IsTrue(memoryStream.CanRead); // We left the stream open
}
+
+ [Test]
+ public void Dispose_FromByteArray()
+ {
+ var stream = new CodedInputStream(new byte[10]);
+ stream.Dispose();
+ }
}
}
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs index 48bf6d60..98cabd55 100644 --- a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -334,7 +334,7 @@ namespace Google.Protobuf }
// Now test Input stream:
{
- CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0);
+ CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false);
Assert.AreEqual(0, cin.Position);
// Field 1:
uint tag = cin.ReadTag();
@@ -415,5 +415,12 @@ namespace Google.Protobuf Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
}
+
+ [Test]
+ public void Dispose_FromByteArray()
+ {
+ var stream = new CodedOutputStream(new byte[10]);
+ stream.Dispose();
+ }
}
}
\ No newline at end of file |