private void Test_Read1() { string s; string crlf = "\r\n"; var stream = new TestStream(false, B( "ab\r\r\n" + "e" + (s = "fgh" + crlf + "ijkl" + crlf + "mnop" + crlf + crlf + crlf + crlf + "qrst") + crlf + "!" )); int s_crlf_count = 6; var io = new RubyIO(Context, stream, "r"); Assert(io.PeekByte() == (byte)'a'); var buffer = MutableString.CreateBinary(B("foo:")); Assert(io.AppendBytes(buffer, 4) == 4); Assert(buffer.ToString() == "foo:ab\r\n"); buffer = MutableString.CreateBinary(); Assert(io.AppendBytes(buffer, 1) == 1); Assert(buffer.ToString() == "e"); buffer = MutableString.CreateMutable("x:"); int c = s.Length - s_crlf_count - 2; Assert(io.AppendBytes(buffer, c) == c); Assert(buffer.ToString() == "x:" + s.Replace(crlf, "\n").Substring(0, c)); buffer = MutableString.CreateBinary(); Assert(io.AppendBytes(buffer, 10) == 4); Assert(buffer.ToString() == "st\n!"); buffer = MutableString.CreateBinary(); Assert(io.AppendBytes(buffer, 10) == 0); Assert(buffer.ToString() == ""); }