mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkReaderTest to reach 100% NetworkReader coverage
This commit is contained in:
parent
e798ac45de
commit
9d7513925f
33
Assets/Mirror/Tests/NetworkReaderTest.cs
Normal file
33
Assets/Mirror/Tests/NetworkReaderTest.cs
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Tests/NetworkReaderTest.cs.meta
Normal file
11
Assets/Mirror/Tests/NetworkReaderTest.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3799af27efdf144909de8790851053a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user