mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
test: Test packing floats into ushort
This commit is contained in:
parent
ad2bee222a
commit
a800064d8a
@ -1,4 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
@ -21,5 +23,17 @@ public void ScaleByteToFloat()
|
||||
Assert.That(FloatBytePacker.ScaleByteToFloat(191, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(0.4980392f).Within(0.0001f));
|
||||
Assert.That(FloatBytePacker.ScaleByteToFloat(255, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(1).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPackFloatToUShort()
|
||||
{
|
||||
ushort packed = FloatBytePacker.PackThreeFloatsIntoUShort(15, 95, 170, 0, 360);
|
||||
|
||||
Vector3 unpacked = FloatBytePacker.UnpackUShortIntoThreeFloats(packed, 0, 360);
|
||||
|
||||
Assert.That(unpacked.x, Is.EqualTo(15).Within(10f));
|
||||
Assert.That(unpacked.y, Is.EqualTo(95).Within(10f));
|
||||
Assert.That(unpacked.z, Is.EqualTo(170).Within(10f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user