File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
src/LinkDotNet.StringBuilder
tests/LinkDotNet.StringBuilder.UnitTests Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
66
77## [ Unreleased]
88
9+ ### Added
10+ - New ctor that accepts an initial size
11+
912## [ 1.19.1] - 2024-04-19
1013
1114### Changed
Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ public ValueStringBuilder(ReadOnlySpan<char> initialText)
5555 Append ( initialText ) ;
5656 }
5757
58+ /// <summary>
59+ /// Initializes a new instance of the <see cref="ValueStringBuilder"/> struct.
60+ /// </summary>
61+ /// <param name="initialCapacity">The initial capacity that will be allocated for this instance.</param>
62+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
63+ public ValueStringBuilder ( int initialCapacity )
64+ {
65+ Grow ( initialCapacity ) ;
66+ }
67+
5868 /// <summary>
5969 /// Gets the current length of the represented string.
6070 /// </summary>
Original file line number Diff line number Diff line change @@ -505,12 +505,20 @@ public void GivenAString_WhenEnumerating_ThenShouldReturnCharacters()
505505 }
506506
507507 [ Fact ]
508- public void GivenStringBuilder_WhenDisposed_ThenEmtpyStringReturned ( )
508+ public void GivenStringBuilder_WhenDisposed_ThenEmptyStringReturned ( )
509509 {
510510 var builder = new ValueStringBuilder ( "Hello World" ) ;
511511
512512 builder . Dispose ( ) ;
513513
514514 builder . ToString ( ) . Should ( ) . Be ( string . Empty ) ;
515515 }
516+
517+ [ Fact ]
518+ public void ShouldInitializeWithCapacity ( )
519+ {
520+ using var builder = new ValueStringBuilder ( 128 ) ;
521+
522+ builder . Capacity . Should ( ) . Be ( 128 ) ;
523+ }
516524}
You can’t perform that action at this time.
0 commit comments