removing old tests (#2165)

these are covered by CollectionWriterTests.gen.cs
This commit is contained in:
James Frowen 2020-08-17 12:01:33 +01:00 committed by GitHub
parent e2fd19547c
commit 901898e897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 156 deletions

View File

@ -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
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7f4698aeeb4f71441a21cc368bd26377
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: