Exemplo n.º 1
0
		public void MarkLongDistanceAndReplay() {
			using (TestStringReader reader = new TestStringReader(1024*20)) {
				TextBuffer charBuffer = new TextBuffer(reader);
				char ch;
				LineInfo position;
				Assert.Equal(reader.ToString().Substring(0, 128), charBuffer.Read(128, out position));
				int offset = 0;
				for (int i = 128; i < 1024*16; i++) {
					Assert.True(charBuffer.TryLookahead(ref offset, out ch));
					Assert.Equal(reader[i], ch);
				}
				offset = 0;
				for (int i = 128; i < 1024*8; i++) {
					Assert.True(charBuffer.TryLookahead(ref offset, out ch));
					Assert.Equal(reader[i], ch);
				}
				Assert.Equal(reader.ToString().Substring(128), charBuffer.Read(reader.Length-128, out position));
				Assert.False(charBuffer.TryLookahead(0, out ch));
			}
		}
Exemplo n.º 2
0
		public void ReadAndRollback() {
			using (TestStringReader reader = new TestStringReader(1024*20)) {
				TextBuffer charBuffer = new TextBuffer(reader);
				LineInfo position1;
				Assert.Equal(reader.ToString().Substring(0, 1280), charBuffer.Read(1280, out position1));
				Assert.Equal(charBuffer.Position, 1280);
				charBuffer.Rollback();
				Assert.Equal(charBuffer.Position, 0);
				LineInfo position2;
				Assert.Equal(reader.ToString().Substring(0, 1280), charBuffer.Read(1280, out position2));
				Assert.Equal(position1, position2);
			}
		}