File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
tests/LinkDotNet.StringBuilder.UnitTests Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Linq ;
23
34namespace LinkDotNet . StringBuilder . UnitTests ;
45
@@ -7,12 +8,11 @@ public class ValueStringBuilderReplaceTests
78 [ Fact ]
89 public void ShouldReplaceAllCharacters ( )
910 {
10- using var builder = new ValueStringBuilder ( ) ;
11- builder . Append ( "CCCC" ) ;
11+ using var builder = new ValueStringBuilder ( new string ( 'C' , 100 ) ) ;
1212
1313 builder . Replace ( 'C' , 'B' ) ;
1414
15- builder . ToString ( ) . Should ( ) . Be ( "BBBB ") ;
15+ builder . ToString ( ) . Should ( ) . MatchRegex ( "[B]{100} ") ;
1616 }
1717
1818 [ Fact ]
@@ -178,6 +178,17 @@ public void ShouldReplaceNonISpanFormattableInSlice()
178178 builder . ToString ( ) . Should ( ) . Be ( "HelloHello{0}" ) ;
179179 }
180180
181+ [ Fact ]
182+ public void ShouldReplaceAllOccurrences ( )
183+ {
184+ var content = string . Join ( string . Empty , Enumerable . Range ( 0 , 100 ) . Select ( _ => "AB" ) ) ;
185+ using var builder = new ValueStringBuilder ( content ) ;
186+
187+ builder . Replace ( "A" , "C" ) ;
188+
189+ builder . ToString ( ) . Should ( ) . MatchRegex ( "[CB]{100}" ) ;
190+ }
191+
181192 private struct MyStruct
182193 {
183194 public override string ToString ( ) => "Hello" ;
You can’t perform that action at this time.
0 commit comments