Skip to content

Commit d62f70e

Browse files
committed
Added some missing tests
1 parent 1153c07 commit d62f70e

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

tests/LinkDotNet.StringBuilder.UnitTests/ValueStringBuilder.Append.Tests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void ShouldThrowIfNotAppendable()
119119

120120
try
121121
{
122-
builder.Insert(0, Guid.Empty, bufferSize: 1);
122+
builder.Append(Guid.Empty, bufferSize: 1);
123123
}
124124
catch (InvalidOperationException)
125125
{
@@ -129,4 +129,16 @@ public void ShouldThrowIfNotAppendable()
129129

130130
Assert.False(true);
131131
}
132+
133+
[Theory]
134+
[InlineData(true, "True")]
135+
[InlineData(false, "False")]
136+
public void ShouldAppendBoolean(bool value, string expected)
137+
{
138+
using var builder = new ValueStringBuilder();
139+
140+
builder.Append(value);
141+
142+
builder.ToString().Should().Be(expected);
143+
}
132144
}

tests/LinkDotNet.StringBuilder.UnitTests/ValueStringBuilder.Insert.Tests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,14 @@ public void ShouldThrowIfNotInsertable()
134134

135135
Assert.False(true);
136136
}
137+
138+
[Fact]
139+
public void ShouldInsertBool()
140+
{
141+
using var builder = new ValueStringBuilder();
142+
143+
builder.Insert(0, true);
144+
145+
builder.ToString().Should().Be("True");
146+
}
137147
}

tests/LinkDotNet.StringBuilder.UnitTests/ValueStringBuilderTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,28 @@ public void ImplicitCastFromReadOnlySpanToValueStringBuilder()
416416

417417
sb.ToString().Should().Be("Hello World");
418418
}
419+
420+
[Fact]
421+
public void ConcatArbitraryValues()
422+
{
423+
var result = ValueStringBuilder.Concat(new[] { "Hello", " ", "World" });
424+
425+
result.Should().Be("Hello World");
426+
}
427+
428+
[Fact]
429+
public void ShouldReturnEmptyStringIfEmptyArray()
430+
{
431+
var result = ValueStringBuilder.Concat(Array.Empty<string>());
432+
433+
result.Should().Be(string.Empty);
434+
}
435+
436+
[Fact]
437+
public void ConcatBooleanWithNumber()
438+
{
439+
var result = ValueStringBuilder.Concat(true, 1);
440+
441+
result.Should().Be("True1");
442+
}
419443
}

0 commit comments

Comments
 (0)