public void TestCorruptStrings()
        {
            var chars = new char[char.MaxValue];

            for (var i = char.MinValue; i < chars.Length; i++)
            {
                chars[i] = i;
            }
            var str = new string(chars);
            var sb  = new StringHelper.LiteStringBuilder();

            sb.Append(chars);

            Assert.AreEqual(sb.ToString(), str);

            Assert.AreEqual(sb.Length, str.Length);
            Assert.AreEqual(sb.ToString().Length, sb.Length);


            sb.Clear();
            var singleByteString = "s";
            var doubleByteString = "ß";
            var quadByteString   = "𝟘";

            sb.Append(singleByteString);
            Assert.AreEqual(sb.ToString(), singleByteString);

            sb.Append(doubleByteString);
            Assert.AreEqual(sb.ToString(), singleByteString + doubleByteString);

            sb.Append(quadByteString);
            Assert.AreEqual(sb.ToString(), singleByteString + doubleByteString + quadByteString);
        }
        public void TestLength()
        {
            var sb = new StringHelper.LiteStringBuilder();

            Assert.IsTrue(sb.Length == 0);
            sb.Append("Hello");
            Assert.IsTrue(sb.Length == 5);
        }
        public void TestIsEmpty()
        {
            var sb = new StringHelper.LiteStringBuilder();

            Assert.IsTrue(sb.IsEmpty());
            sb.Append("Hello");
            Assert.IsFalse(sb.IsEmpty());
        }
        public void TestClear()
        {
            var sb = new StringHelper.LiteStringBuilder();

            Assert.IsTrue(sb.IsEmpty());
            sb.Append("Hello");
            Assert.IsFalse(sb.IsEmpty());
            Assert.AreEqual(sb.ToString(), "Hello");
            sb.Clear();
            Assert.IsTrue(sb.IsEmpty());
            Assert.AreEqual(sb.ToString(), "");
        }
        public void TestLiteStringBuilderThreaded()
        {
            var list = new System.Collections.Concurrent.ConcurrentDictionary <int, string>();

            System.Threading.Tasks.Parallel.For(0, 1000, (i) =>
            {
                var fs = new StringHelper.LiteStringBuilder(1);
                fs.Append(GetString((char)(48 + (i % 10))));
                list.TryAdd(i, fs.ToString());
            });

            var dic = list.ToArray();

            for (var i = 0; i < 1000; i++)
            {
                var key   = dic[i].Key;
                var value = dic[i].Value;
                var str   = GetString((char)(48 + (key % 10)));
                if (string.Compare(str, value) != 0)
                {
                    Assert.Fail("Not thread safe");
                }
            }
        }