17 private byte[] _bytes;
21 _bytes =
new byte[128];
22 for (
int i = 0; i < _bytes.Length; i++) {
23 _bytes[i] = (byte)
UnityEngine.Random.Range(
int.MinValue,
int.MaxValue);
29 UInt16 expected = BitConverter.ToUInt16(_bytes, 0);
30 UInt16 actual = BitConverterNonAlloc.ToUInt16(_bytes, 0);
32 Assert.That(actual, Is.EqualTo(expected));
37 UInt16 value = (UInt16)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
38 var actual = BitConverter.GetBytes(value);
41 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
43 Assert.That(offset, Is.EqualTo(actual.Length));
44 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
49 Int16 expected = BitConverter.ToInt16(_bytes, 0);
50 Int16 actual = BitConverterNonAlloc.ToInt16(_bytes, 0);
52 Assert.That(actual, Is.EqualTo(expected));
57 Int16 value = (Int16)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
58 var actual = BitConverter.GetBytes(value);
61 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
63 Assert.That(offset, Is.EqualTo(actual.Length));
64 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
69 UInt32 expected = BitConverter.ToUInt32(_bytes, 0);
70 UInt32 actual = BitConverterNonAlloc.ToUInt32(_bytes, 0);
72 Assert.That(actual, Is.EqualTo(expected));
77 UInt32 value = (UInt32)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
78 var actual = BitConverter.GetBytes(value);
81 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
83 Assert.That(offset, Is.EqualTo(actual.Length));
84 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
89 Int32 expected = BitConverter.ToInt32(_bytes, 0);
90 Int32 actual = BitConverterNonAlloc.ToInt32(_bytes, 0);
92 Assert.That(actual, Is.EqualTo(expected));
97 Int32 value = (Int32)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
98 var actual = BitConverter.GetBytes(value);
101 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
103 Assert.That(offset, Is.EqualTo(actual.Length));
104 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
109 UInt64 expected = BitConverter.ToUInt64(_bytes, 0);
110 UInt64 actual = BitConverterNonAlloc.ToUInt64(_bytes, 0);
112 Assert.That(actual, Is.EqualTo(expected));
117 UInt64 value = (UInt64)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
118 var actual = BitConverter.GetBytes(value);
121 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
123 Assert.That(offset, Is.EqualTo(actual.Length));
124 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
129 Int64 expected = BitConverter.ToInt64(_bytes, 0);
130 Int64 actual = BitConverterNonAlloc.ToInt64(_bytes, 0);
132 Assert.That(actual, Is.EqualTo(expected));
137 Int64 value = (Int64)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
138 var actual = BitConverter.GetBytes(value);
141 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
143 Assert.That(offset, Is.EqualTo(actual.Length));
144 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
149 Single expected = BitConverter.ToSingle(_bytes, 0);
150 Single actual = BitConverterNonAlloc.ToSingle(_bytes, 0);
152 Assert.That(actual, Is.EqualTo(expected));
157 Single value = (Single)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
158 var actual = BitConverter.GetBytes(value);
161 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
163 Assert.That(offset, Is.EqualTo(actual.Length));
164 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));
169 Double expected = BitConverter.ToDouble(_bytes, 0);
170 Double actual = BitConverterNonAlloc.ToDouble(_bytes, 0);
172 Assert.That(actual, Is.EqualTo(expected));
177 Double value = (Double)
UnityEngine.Random.Range(
float.MinValue,
float.MaxValue);
178 var actual = BitConverter.GetBytes(value);
181 BitConverterNonAlloc.GetBytes(value, _bytes, ref offset);
183 Assert.That(offset, Is.EqualTo(actual.Length));
184 Assert.That(_bytes.Take(offset), Is.EquivalentTo(actual));