public void initial_state() { PicoBuffer b = new PicoBuffer(0); Assert.AreEqual(b.get_pos(), 0); Assert.AreEqual(b.get_size(), 2048); b.delete(); }
public void append_string() { PicoBuffer b; b = new PicoBuffer(3); b.append("1234567890"); Assert.AreEqual(b.get_pos(), 10); Assert.AreEqual(b.get_size() % 3, 0); Assert.AreEqual(b.to_string(), "1234567890"); b.delete(); }
public void truncate() { PicoBuffer b; b = new PicoBuffer(3); b.append("1234567890"); b.truncate(6); Assert.AreEqual(b.get_pos(), 4); Assert.AreEqual(b.get_size(), 6); Assert.AreEqual(b.to_string(), "1234"); b.delete(); }
public void append_buffer() { PicoBuffer b; PicoBuffer b2; b = new PicoBuffer(3); b2 = new PicoBuffer(3); b.append("12345"); b2.append("67890"); Assert.AreEqual(b.get_pos(), 5); Assert.AreEqual(b.get_size() % 3, 0); Assert.AreEqual(b2.get_pos(), 5); Assert.AreEqual(b2.get_size() % 3, 0); b2.append(b); Assert.AreEqual(b2.to_string(), "6789012345"); b.delete(); b2.delete(); }
public void length_prepend() { PicoBuffer b; PicoBuffer b2; b = new PicoBuffer(3); b2 = new PicoBuffer(3); b2.append("67890"); Assert.AreEqual(b2.get_pos(), 5); Assert.AreEqual(b2.get_size() % 3, 0); b.append_lengthprepend(b2); byte[] expected = new byte[] { 0x00, 0x00, 0x00, 0x05, Convert.ToByte('6'), Convert.ToByte('7'), Convert.ToByte('8'), Convert.ToByte('9'), Convert.ToByte('0'), 0x00 }; byte[] ret = new byte[10]; b.copy_to_array(ret, 10); CollectionAssert.AreEqual(ret, expected); b.delete(); b2.delete(); }