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); }
public void PtrWrite() { PtrWriter writer = new PtrWriter(m_ptrBuf, AMOUNT * sizeof(int)); for (int i = 0; i < AMOUNT; i++) { writer.Write(i); } }
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>()); }
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>(); } }