Esempio n. 1
0
        public void TestFloatArray()
        {
            float[] expectedValues = new float[byte.MaxValue - 1];

            for (int i = 0; i < expectedValues.Length; i++)
            {
                expectedValues[i] = (float)(r.NextDouble() * float.MaxValue);
            }

            buffer.WriteFloatArray(expectedValues);

            Assert.IsFalse(buffer.IsFull);
            Assert.AreEqual(expectedValues.Length * sizeof(float) + 1, buffer.Count);

            buffer.Reset();
            Assert.AreEqual(0, buffer.Position);

            float[] actualValues = buffer.ReadFloatArray();

            Assert.AreEqual(expectedValues.Length, actualValues.Length);

            for (int i = 0; i < expectedValues.Length; i++)
            {
                Assert.AreEqual(expectedValues[i], actualValues[i]);
            }

            buffer.Wipe();
            Assert.AreEqual(0, buffer.Count);
        }