public async Task CharIndexToStreamPositionTest_TooBigIdx() { StreamTextAccess buf = new StreamTextAccess( S().Add('a', blockSz).ToStream(Encoding.UTF8), Encoding.UTF8 ); await buf.BeginReading(0, TextAccessDirection.Forward); Assert.Throws <ArgumentOutOfRangeException>(() => buf.CharIndexToPosition(blockSz + 10)); }
public void CharIndexToStreamPositionTest_NegativeIdx() { StreamTextAccess buf = new StreamTextAccess( S().Add('a', blockSz).ToStream(Encoding.UTF8), Encoding.UTF8 ); buf.BeginReading(0, TextAccessDirection.Forward); Assert.Throws <ArgumentOutOfRangeException>(() => buf.CharIndexToPosition(-1)); }
static void TestCharPosMapping(StreamTextAccess sut, TextStreamPosition pos, int charIdx) { Assert.AreEqual(pos.Value, sut.CharIndexToPosition(charIdx).Value); Assert.AreEqual(charIdx, sut.PositionToCharIndex(pos)); }