public void testWrite_CH_DATA() { SideBandOutputStream o; o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.SMALL_BUF, rawOut); byte[] b = new byte[] { (byte)'a', (byte)'b', (byte)'c' }; o.Write(b, 0, b.Length); o.Flush(); assertBuffer("0008\x01" + "abc"); }
public void testWrite_Large() { const int buflen = SideBandOutputStream.MAX_BUF - SideBandOutputStream.HDR_SIZE; byte[] buf = new byte[buflen]; for (int i = 0; i < buf.Length; i++) buf[i] = (byte)i; SideBandOutputStream o; o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.MAX_BUF, rawOut); o.Write(buf, 0, buf.Length); o.Flush(); byte[] act = rawOut.ToArray(); string explen = NB.DecimalToBase(buf.Length + SideBandOutputStream.HDR_SIZE, 16); Assert.AreEqual(SideBandOutputStream.HDR_SIZE + buf.Length, act.Length); Assert.AreEqual(Charset.forName("UTF-8").GetString(act, 0, 4), explen); Assert.AreEqual(1, act[4]); for (int i = 0, j = SideBandOutputStream.HDR_SIZE; i < buf.Length; i++, j++) Assert.AreEqual(buf[i], act[j]); }
public void testWrite_SmallBlocks1() { SideBandOutputStream o; o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, 6, rawOut); o.WriteByte((byte)'a'); o.WriteByte((byte)'b'); o.WriteByte((byte)'c'); o.Flush(); assertBuffer("0006\x01" + "a0006\x01" + "b0006\x01" + "c"); }
public void testWrite_SmallBlocks3() { SideBandOutputStream o; o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, 7, rawOut); o.WriteByte((byte)'a'); o.Write(new byte[] { (byte)'b', (byte)'c' }, 0, 2); o.Flush(); assertBuffer("0007\x01" + "ab0006\x01" + "c"); }
public void testWrite_Small() { SideBandOutputStream o; o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.SMALL_BUF, rawOut); o.WriteByte((byte)'a'); o.WriteByte((byte)'b'); o.WriteByte((byte)'c'); o.Flush(); assertBuffer("0008\x01" + "abc"); }