public bool ReadChar()
{
if (inBuf > 0)
{
--inBuf;
/*
* was : return (char)((char)0xff & buffer[(bufferPosition == bufferSize - 1) ? (bufferPosition = 0) : ++bufferPosition]);
*/
currentCharacterAvailable = true;
currentCharacter = buffer[(bufferPosition == bufferSize - 1) ? (bufferPosition = 0) : ++bufferPosition];
return true;
}
if (++bufferPosition >= maxNextCharInd)
{
if (!FillBuff())
{
currentCharacterAvailable = false;
currentCharacter = default(Char);
return false;
}
}
/*
* was : char c = (char)((char)0xff & buffer[bufferPosition]);
*/
currentCharacterAvailable = true;
currentCharacter = buffer[bufferPosition];
UpdateLineColumn();
return true;
}
public void Test_VelocityCharStream() { String s1 = "this is a test"; VelocityCharStream vcs = new VelocityCharStream(new StringReader(s1), 1, 1); String s2 = String.Empty; try { Char c = vcs.ReadChar(); while (true) { s2 += c; c = vcs.ReadChar(); } } catch (IOException) { // this is expected to happen when the stream has been read } Assert.IsTrue(s1.Equals(s2), "read stream did not match source string"); }