Ejemplo n.º 1
0
        public void Reverse_CanReversePartOfString_WhenLengthIsOdd(int start, int length, string expected)
        {
            // Arrange
            var builder = new FastStringBuilder("abcdefg");

            // Act
            builder.Reverse(start, length);

            // Assert
            Assert.AreEqual(expected, builder.ToString());
        }
Ejemplo n.º 2
0
        public void Reverse_CanReverseTheWholeString_WhenLengthIsOdd()
        {
            // Arrange
            var builder = new FastStringBuilder("abcdefg");

            // Act
            builder.Reverse(0, builder.Length);

            // Assert
            Assert.AreEqual("gfedcba", builder.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Fixes rich text tags in input string and returns the result.
        /// </summary>
        public static void Fix(FastStringBuilder text)
        {
            for (int i = 0; i < text.Length; i++)
            {
                FindTag(text, i, out Tag tag);

                // If we couldn't find a tag, end the process
                if (tag.Type == TagType.None)
                {
                    break;
                }

                text.Reverse(tag.Start, tag.End - tag.Start + 1);

                i = tag.End;
            }
        }