public void TestClear() { var buffer = new CharacterBuffer(); buffer.Append('a'); buffer.Append('b'); buffer.Clear(); buffer.Append('c'); Assert.AreEqual(buffer.DisposeAndGetContents(), "c"); }
public void TestBuildString() { var buffer = new CharacterBuffer(); var s = "Some test string"; for (int i = 0; i < s.Length; i++) buffer.Append(s[i]); Assert.AreEqual(buffer.DisposeAndGetContents(), s); }
void ProcessDecodedChars() { char value; while (Parent.GetCurrentCharacterAndAdvance(out value)) { Buffer.Append(value); } var decodeMoreChars = Parent.DecodeMoreData(); decodeMoreChars.RegisterOnComplete(OnDecodeComplete); }
public void TestRemoveLastCharacter() { var buffer = new CharacterBuffer(); int size = buffer.Capacity; for (int i = 0; i < size; i++) buffer.Append('a'); for (int i = 0; i < size; i++) buffer.Remove(buffer.Length - 1, 1); buffer.Dispose(); }
private bool ReadDecodedCharactersUntilSentinel(CharacterBuffer buffer, char sentinel) { bool result = false; int startOffset = _DecodedCharacterOffset; while (_DecodedCharacterOffset < _DecodedCharacterCount) { if (_DecodedBuffer[_DecodedCharacterOffset++] == sentinel) { result = true; break; } } int charCount = _DecodedCharacterOffset - startOffset; if (result) { charCount -= 1; } buffer.Append(_DecodedBuffer, startOffset, charCount); return(result); }
private bool ReadDecodedCharactersUntilSentinel(CharacterBuffer buffer, char sentinel) { bool result = false; int startOffset = _DecodedCharacterOffset; while (_DecodedCharacterOffset < _DecodedCharacterCount) { if (_DecodedBuffer[_DecodedCharacterOffset++] == sentinel) { result = true; break; } } int charCount = _DecodedCharacterOffset - startOffset; if (result) charCount -= 1; buffer.Append(_DecodedBuffer, startOffset, charCount); return result; }