public void Rent_Free_SingleItem()
        {
            var sb = StringBuilderPool.Rent();

            Check.That(sb).IsNotNull();

            //Check.That(sb.Capacity)
            //	.IsEqualTo(StringBuilderPool.InitialCapacity);
            Check.That(sb.Length).IsEqualTo(0);

            sb.Append("abc");

            //Check.That(sb.Capacity)
            //	.IsEqualTo(StringBuilderPool.InitialCapacity);
            Check.That(sb.Length).IsEqualTo(3);

            StringBuilderPool.Free(sb);

            //Check.That(sb.Capacity)
            //	.IsEqualTo(StringBuilderPool.InitialCapacity);
            Check.That(sb.Length).IsEqualTo(0);
        }
Exemplo n.º 2
0
        private static String _Format(
            String[] strings,
            Byte[] buffer,
            Int32 offset,
            Int32 count,
            String delimiter
            )
        {
            StringBuilder?sb = null;

            try
            {
                sb = StringBuilderPool.Rent();

                for (var i = offset; i < offset + count; i++)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(delimiter);
                    }

                    if (i > offset && (i - offset) % 8 == 0)
                    {
                        sb.Append(delimiter);
                    }

                    sb.Append(strings[buffer[i]]);
                }

                return(sb.ToString());
            }
            finally
            {
                StringBuilderPool.Free(sb);
            }
        }
 public void Free_Ignores_Null()
 {
     Check.ThatCode(() => StringBuilderPool.Free(null)).DoesNotThrow();
 }