diff --git a/Assets/Mirror/Tests/NetworkReaderTest.cs b/Assets/Mirror/Tests/NetworkReaderTest.cs new file mode 100644 index 000000000..8d92350b3 --- /dev/null +++ b/Assets/Mirror/Tests/NetworkReaderTest.cs @@ -0,0 +1,33 @@ +using System; +using System.IO; +using NUnit.Framework; +using UnityEngine; + +namespace Mirror.Tests +{ + // NetworkWriterTest already covers most cases for NetworkReader. + // only a few are left + [TestFixture] + public class NetworkReaderTest + { + [Test] + public void ReadBytesCountTooBigTest() + { + // calling ReadBytes with a count bigger than what is in Reader + // should throw an exception + byte[] bytes = {0x00, 0x01}; + NetworkReader reader = new NetworkReader(bytes); + + try + { + byte[] result = reader.ReadBytes(bytes, bytes.Length + 1); + // BAD: IF WE GOT HERE, THEN NO EXCEPTION WAS THROWN + Assert.Fail(); + } + catch (EndOfStreamException) + { + // GOOD + } + } + } +} diff --git a/Assets/Mirror/Tests/NetworkReaderTest.cs.meta b/Assets/Mirror/Tests/NetworkReaderTest.cs.meta new file mode 100644 index 000000000..ce21bed1d --- /dev/null +++ b/Assets/Mirror/Tests/NetworkReaderTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3799af27efdf144909de8790851053a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: