Skip to content

Commit

Permalink
Test for adding to TypedSpanList
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Mar 2, 2024
1 parent fcc0126 commit ae63be0
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;

namespace LinkDotNet.StringBuilder.UnitTests;

Expand All @@ -7,12 +8,11 @@ public class ValueStringBuilderReplaceTests
[Fact]
public void ShouldReplaceAllCharacters()
{
using var builder = new ValueStringBuilder();
builder.Append("CCCC");
using var builder = new ValueStringBuilder(new string('C', 100));

builder.Replace('C', 'B');

builder.ToString().Should().Be("BBBB");
builder.ToString().Should().MatchRegex("[B]{100}");
}

[Fact]
Expand Down Expand Up @@ -178,6 +178,17 @@ public void ShouldReplaceNonISpanFormattableInSlice()
builder.ToString().Should().Be("HelloHello{0}");
}

[Fact]
public void ShouldReplaceAllOccurrences()
{
var content = string.Join(string.Empty, Enumerable.Range(0, 100).Select(_ => "AB"));
using var builder = new ValueStringBuilder(content);

builder.Replace("A", "C");

builder.ToString().Should().MatchRegex("[CB]{100}");
}

private struct MyStruct
{
public override string ToString() => "Hello";
Expand Down

0 comments on commit ae63be0

Please sign in to comment.