public void ParsingTextReaderBlockingComplexReadBlock3() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader, 2); char[] cs = new char[10]; int start = 0; while (!reader.EndOfStream) { int read = reader.ReadBlock(cs, 0, cs.Length); Assert.IsTrue(read <= 10); if (read == 0) { break; } String s = new string(cs, 0, read); Assert.AreEqual(TestData.Substring(start, read), s); start += 10; } Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }
public void ParsingTextReaderBlockingSimplePeek() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader); for (int i = 1; i <= 100; i++) { char c = (char)reader.Peek(); Console.WriteLine("Peek #" + i + " = " + c); Assert.AreEqual(TestData[0], c); } Assert.IsFalse(reader.EndOfStream); Assert.AreNotEqual(-1, reader.Peek()); Assert.AreNotEqual(-1, reader.Read()); reader.Close(); }
public void ParsingTextReaderBlockingReadLine() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader); String s = reader.ReadLine(); Assert.AreEqual(TestData, s); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }
public void ParsingTextReaderBlockingReadLine5() { StringReader strReader = new StringReader(TestData5); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader); String s = reader.ReadLine(); Assert.Equal(TestData5.Substring(0, 26), s); s = reader.ReadLine(); Assert.Equal(TestData5.Substring(28), s); Assert.Equal(-1, reader.Peek()); Assert.Equal(-1, reader.Read()); reader.Close(); }
public void ParsingBlockingTextReaderSimpleReadBlock() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader); char[] cs = new char[100]; int read = reader.ReadBlock(cs, 0, cs.Length); Assert.AreEqual(TestData.Length, read); Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); String s = new string(cs, 0, read); Assert.AreEqual(TestData, s); }
public void ParsingTextReaderBlockingSimpleReadBlock() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader); char[] cs = new char[100]; int read = reader.ReadBlock(cs, 0, cs.Length); Assert.AreEqual(TestData.Length, read); Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); String s = new string(cs, 0, read); Assert.AreEqual(TestData, s); }
public void ParsingBlockingTextReaderSimpleRead() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader); StringBuilder output = new StringBuilder(); while (!reader.EndOfStream) { output.Append((char)reader.Read()); } Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); Console.WriteLine(output.ToString()); Assert.AreEqual(TestData, output.ToString()); }
public void ParsingTextReaderBlockingSimpleRead() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader); StringBuilder output = new StringBuilder(); while (!reader.EndOfStream) { output.Append((char)reader.Read()); } Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); Console.WriteLine(output.ToString()); Assert.AreEqual(TestData, output.ToString()); }
public void ParsingBlockingTextReaderReadToEnd() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader); String s = reader.ReadToEnd(); Assert.AreEqual(TestData, s); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }
public void ParsingBlockingTextReaderComplexReadBlock3() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader, 2); char[] cs = new char[10]; int start = 0; while (!reader.EndOfStream) { int read = reader.ReadBlock(cs, 0, cs.Length); Assert.IsTrue(read <= 10); if (read == 0) break; String s = new string(cs, 0, read); Assert.AreEqual(TestData.Substring(start, read), s); start += 10; } Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }
public void ParsingBlockingTextReaderSimplePeek() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader); for (int i = 1; i <= 100; i++) { char c = (char)reader.Peek(); Console.WriteLine("Peek #" + i + " = " + c); Assert.AreEqual(TestData[0], c); } Assert.IsFalse(reader.EndOfStream); Assert.AreNotEqual(-1, reader.Peek()); Assert.AreNotEqual(-1, reader.Read()); reader.Close(); }
public void ParsingBlockingTextReaderReadLine5() { StringReader strReader = new StringReader(TestData5); BlockingTextReader reader = new BlockingTextReader(strReader); String s = reader.ReadLine(); Assert.AreEqual(TestData5.Substring(0, 26), s); s = reader.ReadLine(); Assert.AreEqual(TestData5.Substring(28), s); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }