File tree 3 files changed +22
-1
lines changed
src/LinkDotNet.StringBuilder
tests/LinkDotNet.StringBuilder.UnitTests
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
6
6
7
7
## [ Unreleased]
8
8
9
+ ### Added
10
+ - New ctor that accepts an initial size
11
+
9
12
## [ 1.19.1] - 2024-04-19
10
13
11
14
### Changed
Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ public ValueStringBuilder(ReadOnlySpan<char> initialText)
55
55
Append ( initialText ) ;
56
56
}
57
57
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
+
58
68
/// <summary>
59
69
/// Gets the current length of the represented string.
60
70
/// </summary>
Original file line number Diff line number Diff line change @@ -505,12 +505,20 @@ public void GivenAString_WhenEnumerating_ThenShouldReturnCharacters()
505
505
}
506
506
507
507
[ Fact ]
508
- public void GivenStringBuilder_WhenDisposed_ThenEmtpyStringReturned ( )
508
+ public void GivenStringBuilder_WhenDisposed_ThenEmptyStringReturned ( )
509
509
{
510
510
var builder = new ValueStringBuilder ( "Hello World" ) ;
511
511
512
512
builder . Dispose ( ) ;
513
513
514
514
builder . ToString ( ) . Should ( ) . Be ( string . Empty ) ;
515
515
}
516
+
517
+ [ Fact ]
518
+ public void ShouldInitializeWithCapacity ( )
519
+ {
520
+ using var builder = new ValueStringBuilder ( 128 ) ;
521
+
522
+ builder . Capacity . Should ( ) . Be ( 128 ) ;
523
+ }
516
524
}
You can’t perform that action at this time.
0 commit comments