コード例 #1
0
        public void TestFloat()
        {
            int maxFloats     = buffer.Size / sizeof(float);
            int expectedCount = maxFloats * sizeof(float);

            float[] expected = new float[maxFloats];

            for (int i = 0; i < maxFloats; i++)
            {
                expected[i] = (float)(r.NextDouble() * float.MaxValue);
                buffer.WriteFloat(expected[i]);
            }

            if (expectedCount == buffer.Size)
            {
                Assert.IsTrue(buffer.IsFull);
            }

            Assert.AreEqual(expectedCount, buffer.Count);

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

            foreach (float f in expected)
            {
                Assert.AreEqual(f, buffer.ReadFloat());
            }

            Assert.AreEqual(0, buffer.Count);
            Assert.AreEqual(expectedCount, buffer.Position);

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