public void TestToInt32() { Int32 expected = BitConverter.ToInt32(_bytes, 0); Int32 actual = BitConverterNonAlloc.ToInt32(_bytes, 0); Assert.That(actual, Is.EqualTo(expected)); }
public void TestToUInt16() { UInt16 expected = BitConverter.ToUInt16(_bytes, 0); UInt16 actual = BitConverterNonAlloc.ToUInt16(_bytes, 0); Assert.That(actual, Is.EqualTo(expected)); }
public void TestToDouble() { Double expected = BitConverter.ToDouble(_bytes, 0); Double actual = BitConverterNonAlloc.ToDouble(_bytes, 0); Assert.That(actual, Is.EqualTo(expected)); }
public void TestFromUInt32() { UInt32 value = (UInt32)UnityEngine.Random.Range(float.MinValue, float.MaxValue); var actual = BitConverter.GetBytes(value); int offset = 0; BitConverterNonAlloc.GetBytes(value, _bytes, ref offset); Assert.That(offset, Is.EqualTo(actual.Length)); Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual)); }