Esempio n. 1
0
        public void TestToInt32()
        {
            Int32 expected = BitConverter.ToInt32(_bytes, 0);
            Int32 actual   = BitConverterNonAlloc.ToInt32(_bytes, 0);

            Assert.That(actual, Is.EqualTo(expected));
        }
Esempio n. 2
0
        public void TestToUInt16()
        {
            UInt16 expected = BitConverter.ToUInt16(_bytes, 0);
            UInt16 actual   = BitConverterNonAlloc.ToUInt16(_bytes, 0);

            Assert.That(actual, Is.EqualTo(expected));
        }
Esempio n. 3
0
        public void TestToDouble()
        {
            Double expected = BitConverter.ToDouble(_bytes, 0);
            Double actual   = BitConverterNonAlloc.ToDouble(_bytes, 0);

            Assert.That(actual, Is.EqualTo(expected));
        }
Esempio n. 4
0
        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));
        }