Пример #1
0
        public void TestClear()
        {
            var buffer = new CharacterBuffer();

            buffer.Append('a');
            buffer.Append('b');

            buffer.Clear();

            buffer.Append('c');

            Assert.AreEqual(buffer.DisposeAndGetContents(), "c");
        }
Пример #2
0
        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);
        }
Пример #3
0
Файл: IO.cs Проект: sq/Libraries
            void ProcessDecodedChars()
            {
                char value;

                while (Parent.GetCurrentCharacterAndAdvance(out value))
                {
                    Buffer.Append(value);
                }

                var decodeMoreChars = Parent.DecodeMoreData();

                decodeMoreChars.RegisterOnComplete(OnDecodeComplete);
            }
Пример #4
0
        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();
        }
Пример #5
0
Файл: IO.cs Проект: sq/Libraries
        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);
        }
Пример #6
0
Файл: IO.cs Проект: sq/Fracture
        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;
        }