Skip to content

Commit 984e559

Browse files
Expanded StringBuilder tests.
1 parent a0710b5 commit 984e559

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Tests/StringBuilderTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,28 @@ public static void ToStringBuilderSeparatedString(string? source, string? separa
220220
[InlineData("Hello there.", " Hello", " ", "there.", "")]
221221
[InlineData("Hello there.", " Hello", " ", "there.", " ")]
222222
[InlineData("Hello there.", "Hello", " ", "there.", " ")]
223+
[InlineData("", "", " ", "", " ")]
224+
[InlineData("", "", "", "", "")]
223225
public static void Trim(string expected, string a, string b, string c, string d)
224226
{
225227
var sb = new StringBuilder();
226228
sb.Append(a).Append(b).Append(c).Append(d).Trim();
227229
Assert.Equal(expected, sb.ToString());
228230
}
231+
232+
// Tests that cover the StringBuilder Trim but with multiple characters to trim using a ReadOnlySpan<char>
233+
[Theory]
234+
// Expected, A, B, C, D
235+
[InlineData("Hello there.", "!Hello", " ", "there.", "")]
236+
[InlineData("Hello there.", " Hello", " ", "there.", "!")]
237+
[InlineData("Hello there.", " ! Hello", " ", "there.!", " ")]
238+
[InlineData("Hello there.", "Hello", " ", "there.", " ")]
239+
[InlineData("", "", " ", "", " ")]
240+
[InlineData("", "", "", "", "")]
241+
public static void TrimChars(string expected, string a, string b, string c, string d)
242+
{
243+
var sb = new StringBuilder();
244+
sb.Append(a).Append(b).Append(c).Append(d).Trim(" !");
245+
Assert.Equal(expected, sb.ToString());
246+
}
229247
}

0 commit comments

Comments
 (0)