public override void Join(string[] array, string expectedResult) { var length = AllocationFree.CalculateRequiredLength(array); Span <char> buffer = stackalloc char[length]; AllocationFree.JoinAndConcatBrackets(array, buffer); Assert.Equal(expectedResult, buffer.ToString()); }
public void AllocationFree_JoinAndConcatBrackets(string[] content) { var length = AllocationFree.CalculateRequiredLength(content); if (length > 1024) { var largeBuffer = ArrayPool <char> .Shared.Rent(length); Span <char> bufferSpan = largeBuffer; AllocationFree.JoinAndConcatBrackets(content, ref bufferSpan); ArrayPool <char> .Shared.Return(largeBuffer); return; } Span <char> buffer = stackalloc char[length]; AllocationFree.JoinAndConcatBrackets(content, ref buffer); }