Example #1
0
        public void ValueTest(int iVal, float fVal, double dVal)
        {
            var pw = new PtrWriter(m_buffer, 64);

            pw.Write(iVal); pw.Write(fVal); pw.Write(dVal);

            var pr = new PtrReader(m_buffer, 64);

            Assert.AreEqual(iVal, pr.Read <int>());
            Assert.AreEqual(fVal, pr.Read <float>());
            Assert.AreEqual(dVal, pr.Read <double>());

            Assert.AreEqual(16, pw.Offset);
            Assert.AreEqual(pr.Offset, pw.Offset);
        }
Example #2
0
        public void PtrRead()
        {
            PtrReader reader = new PtrReader(m_ptrBuf, AMOUNT * sizeof(int));

            for (int i = 0; i < AMOUNT; i++)
            {
                int result = reader.Read <int>();
            }
        }
Example #3
0
        public void PtrWrite()
        {
            PtrWriter writer = new PtrWriter(m_ptrBuf, SIZE);

            for (int i = 0; i < AMOUNT / 2; i++)
            {
                writer.Write(i % 2 == 0);
                writer.Write(i);
            }

            PtrReader reader = new PtrReader(m_ptrBuf, SIZE);

            for (int i = 0; i < AMOUNT / 2; i++)
            {
                bool b   = reader.Read <bool>();
                int  num = reader.Read <int>();
            }
        }
Example #4
0
        public void SizePrefixTest()
        {
            PtrWriter bw = new PtrWriter(m_buffer, 16);

            bw.ReserveSizePrefix();
            bw.Write(1);
            bw.Write(2);
            bw.Write(3);

            Assert.AreEqual(16, bw.Offset);
            Assert.AreEqual(16, bw.Length);

            Assert.AreEqual(16, bw.PrefixSize());

            PtrReader br = new PtrReader(bw.Buffer, 16);

            Assert.AreEqual(16, br.Read <int>());
        }