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

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

            bigBuffer.WriteLongArray(expectedValues);

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

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

            long[] actualValues = bigBuffer.ReadLongArray();

            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 TestPeekLong()
        {
            buffer.WriteLong(1);
            buffer.WriteLong(2);

            buffer.Reset();
            Assert.AreEqual(1, buffer.PeekLong());
            Assert.AreEqual(2, buffer.PeekLong(1 * sizeof(long)));

            buffer.Wipe();

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

            buffer.Wipe();
        }