mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
removing old tests (#2165)
these are covered by CollectionWriterTests.gen.cs
This commit is contained in:
parent
e2fd19547c
commit
901898e897
@ -1,145 +0,0 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Mirror.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArraySegmentWriterTest
|
||||
{
|
||||
#region ArraySegment<byte>
|
||||
|
||||
// ArraySegment<byte> is a special case, optimized for no copy and no allocation
|
||||
// other types are generated by the weaver
|
||||
|
||||
class ByteArraySegmentMessage : MessageBase
|
||||
{
|
||||
public ArraySegment<byte> array;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyByteArray()
|
||||
{
|
||||
ByteArraySegmentMessage message = new ByteArraySegmentMessage
|
||||
{
|
||||
array = new ArraySegment<byte>(new byte[0])
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
|
||||
ByteArraySegmentMessage unpacked = MessagePacker.Unpack<ByteArraySegmentMessage>(data);
|
||||
|
||||
Assert.IsNotNull(unpacked.array.Array);
|
||||
Assert.That(unpacked.array.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
public static ArraySegment<int> SampleReader(NetworkReader reader)
|
||||
{
|
||||
int length = reader.ReadPackedInt32();
|
||||
int[] array = new int[length];
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
array[i] = reader.ReadPackedInt32();
|
||||
}
|
||||
|
||||
return new ArraySegment<int>(array);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullByteArray()
|
||||
{
|
||||
ByteArraySegmentMessage message = new ByteArraySegmentMessage
|
||||
{
|
||||
array = default
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
|
||||
ByteArraySegmentMessage unpacked = MessagePacker.Unpack<ByteArraySegmentMessage>(data);
|
||||
|
||||
Assert.IsNull(unpacked.array.Array);
|
||||
Assert.That(unpacked.array.Offset, Is.EqualTo(0));
|
||||
Assert.That(unpacked.array.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSegmentByteArray()
|
||||
{
|
||||
byte[] sourcedata = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
ByteArraySegmentMessage message = new ByteArraySegmentMessage
|
||||
{
|
||||
array = new ArraySegment<byte>(sourcedata, 3, 2)
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
|
||||
ByteArraySegmentMessage unpacked = MessagePacker.Unpack<ByteArraySegmentMessage>(data);
|
||||
|
||||
Assert.IsNotNull(unpacked.array.Array);
|
||||
Assert.That(unpacked.array.Count, Is.EqualTo(2));
|
||||
Assert.That(unpacked.array, Is.EquivalentTo(new byte[] { 3, 4 }));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ArraySegment<int>
|
||||
|
||||
class IntArraySegmentMessage : MessageBase
|
||||
{
|
||||
public ArraySegment<int> array;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyIntArray()
|
||||
{
|
||||
IntArraySegmentMessage message = new IntArraySegmentMessage
|
||||
{
|
||||
array = new ArraySegment<int>(new int[0])
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
|
||||
IntArraySegmentMessage unpacked = MessagePacker.Unpack<IntArraySegmentMessage>(data);
|
||||
|
||||
Assert.IsNotNull(unpacked.array.Array);
|
||||
Assert.That(unpacked.array.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullIntArray()
|
||||
{
|
||||
IntArraySegmentMessage message = new IntArraySegmentMessage
|
||||
{
|
||||
array = default
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
|
||||
IntArraySegmentMessage unpacked = MessagePacker.Unpack<IntArraySegmentMessage>(data);
|
||||
|
||||
Assert.That(unpacked.array.Offset, Is.EqualTo(0));
|
||||
Assert.That(unpacked.array.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSegmentIntArray()
|
||||
{
|
||||
int[] sourcedata = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
IntArraySegmentMessage message = new IntArraySegmentMessage
|
||||
{
|
||||
array = new ArraySegment<int>(sourcedata, 3, 2)
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
|
||||
IntArraySegmentMessage unpacked = MessagePacker.Unpack<IntArraySegmentMessage>(data);
|
||||
|
||||
Assert.IsNotNull(unpacked.array.Array);
|
||||
Assert.That(unpacked.array.Count, Is.EqualTo(2));
|
||||
Assert.That(unpacked.array, Is.EquivalentTo(new int[] { 3, 4 }));
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f4698aeeb4f71441a21cc368bd26377
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user