Beispiel #1
0
        public void TestDoubleArray()
        {
            double[] expectedValues = new double[byte.MaxValue - 1];

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

            bigBuffer.WriteDoubleArray(expectedValues);

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

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

            double[] actualValues = bigBuffer.ReadDoubleArray();

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

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

            bigBuffer.Wipe();
            Assert.AreEqual(0, bigBuffer.Count);
        }
Beispiel #2
0
        public void TestPeekDouble()
        {
            buffer.WriteDouble(1);
            buffer.WriteDouble(2);

            buffer.Reset();
            Assert.AreEqual(1, buffer.PeekDouble());
            Assert.AreEqual(2, buffer.PeekDouble(1 * sizeof(double)));

            buffer.Wipe();

            buffer.WriteDoubleArray(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            buffer.Reset();
            Assert.AreEqual(4, buffer.PeekDouble(sizeof(byte) + 3 * sizeof(double)));
            Assert.AreEqual(5, buffer.PeekDouble(sizeof(byte) + 4 * sizeof(double)));

            buffer.Wipe();
        }