diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs index 8d939c7..9039f7b 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs @@ -126,6 +126,10 @@ static object CreateFormatter(Type type) { return CreateNullableFormatter(); } + if (type == typeof(System.Boolean?)) + { + return CreateNullableFormatter(); + } if (type == typeof(System.IntPtr)) { // ignore format diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs index ed401d7..518803c 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf16ValueStringBuilder.cs @@ -512,6 +512,9 @@ public bool TryCopyTo(Span destination, out int charsWritten) /// Converts the value of this instance to a System.String. public override string ToString() { + if (index == 0) + return string.Empty; + return new string(buffer, 0, index); } diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs index b04471c..dd58fce 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs @@ -68,6 +68,10 @@ static object CreateFormatter(Type type) { return new TryFormat((System.Guid x, Span dest, out int written, StandardFormat format) => Utf8Formatter.TryFormat(x, dest, out written, format)); } + if (type == typeof(System.Boolean)) + { + return new TryFormat((System.Boolean x, Span dest, out int written, StandardFormat format) => Utf8Formatter.TryFormat(x, dest, out written, format)); + } if (type == typeof(System.Byte?)) { return CreateNullableFormatter(); @@ -128,6 +132,10 @@ static object CreateFormatter(Type type) { return CreateNullableFormatter(); } + if (type == typeof(System.Boolean?)) + { + return CreateNullableFormatter(); + } if (type == typeof(System.IntPtr)) { // ignore format diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs index 1a46010..5321ecb 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs @@ -52,6 +52,7 @@ public void AppendLine(System.Byte value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.DateTime value) @@ -97,6 +98,7 @@ public void AppendLine(System.DateTime value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.DateTimeOffset value) @@ -142,6 +144,7 @@ public void AppendLine(System.DateTimeOffset value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Decimal value) @@ -187,6 +190,7 @@ public void AppendLine(System.Decimal value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Double value) @@ -232,6 +236,7 @@ public void AppendLine(System.Double value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Int16 value) @@ -277,6 +282,7 @@ public void AppendLine(System.Int16 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Int32 value) @@ -322,6 +328,7 @@ public void AppendLine(System.Int32 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Int64 value) @@ -367,6 +374,7 @@ public void AppendLine(System.Int64 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.SByte value) @@ -412,6 +420,7 @@ public void AppendLine(System.SByte value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Single value) @@ -457,6 +466,7 @@ public void AppendLine(System.Single value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.TimeSpan value) @@ -502,6 +512,7 @@ public void AppendLine(System.TimeSpan value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.UInt16 value) @@ -547,6 +558,7 @@ public void AppendLine(System.UInt16 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.UInt32 value) @@ -592,6 +604,7 @@ public void AppendLine(System.UInt32 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.UInt64 value) @@ -637,6 +650,7 @@ public void AppendLine(System.UInt64 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Guid value) @@ -682,5 +696,52 @@ public void AppendLine(System.Guid value, StandardFormat format) Append(value, format); AppendLine(); } + + /// Appends the string representation of a specified value to this instance. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Append(System.Boolean value) + { + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) + { + Grow(written); + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out written)) + { + ThrowArgumentException(nameof(value)); + } + } + index += written; + } + + /// Appends the string representation of a specified value to this instance with numeric format strings. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Append(System.Boolean value, StandardFormat format) + { + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) + { + Grow(written); + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out written, format)) + { + ThrowArgumentException(nameof(value)); + } + } + index += written; + } + + /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void AppendLine(System.Boolean value) + { + Append(value); + AppendLine(); + } + + /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void AppendLine(System.Boolean value, StandardFormat format) + { + Append(value, format); + AppendLine(); + } + } } diff --git a/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs b/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs index 56cfce2..c30b2b2 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/Utf8ValueStringBuilder.cs @@ -313,6 +313,9 @@ public Task WriteToAsync(Stream stream) /// Encode the innner utf8 buffer to a System.String. public override string ToString() { + if (index == 0) + return string.Empty; + return UTF8NoBom.GetString(buffer, 0, index); } diff --git a/src/ZString.Unity/Assets/Scripts/ZString/ZString.Concat.cs b/src/ZString.Unity/Assets/Scripts/ZString/ZString.Concat.cs index 2ab15f6..b97088b 100644 --- a/src/ZString.Unity/Assets/Scripts/ZString/ZString.Concat.cs +++ b/src/ZString.Unity/Assets/Scripts/ZString/ZString.Concat.cs @@ -7,6 +7,11 @@ public static partial class ZString /// Concatenates the string representation of some specified objects. public static string Concat(T1 arg1) { + if (typeof(T1) == typeof(string)) + { + return (arg1 != null) ? Unsafe.As(arg1) : string.Empty; + } + var sb = new Utf16ValueStringBuilder(true); try { diff --git a/src/ZString/T4Common.t4 b/src/ZString/T4Common.t4 index 8ef1a1f..9bd64b6 100644 --- a/src/ZString/T4Common.t4 +++ b/src/ZString/T4Common.t4 @@ -41,4 +41,6 @@ typeof(Guid), // typeof(Version), }; + + var utf8spanFormattables = spanFormattables.Append(typeof(bool)); #> \ No newline at end of file diff --git a/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs b/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs index 8d939c7..9039f7b 100644 --- a/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs +++ b/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.cs @@ -126,6 +126,10 @@ static object CreateFormatter(Type type) { return CreateNullableFormatter(); } + if (type == typeof(System.Boolean?)) + { + return CreateNullableFormatter(); + } if (type == typeof(System.IntPtr)) { // ignore format diff --git a/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt b/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt index 0ccd705..6c373fd 100644 --- a/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt +++ b/src/ZString/Utf16/Utf16ValueStringBuilder.CreateFormatter.tt @@ -57,7 +57,7 @@ namespace Cysharp.Text return new TryFormat<<#= t.FullName #>>((<#= t.FullName #> x, Span dest, out int written, ReadOnlySpan format) => x.TryFormat(dest, out written, format)); } <# } #> -<# foreach(var t in spanFormattables) { #> +<# foreach(var t in spanFormattables.Append(typeof(bool))) { #> if (type == typeof(<#= t.FullName #>?)) { return CreateNullableFormatter<<#= t.FullName #>>(); diff --git a/src/ZString/Utf16ValueStringBuilder.cs b/src/ZString/Utf16ValueStringBuilder.cs index ed401d7..518803c 100644 --- a/src/ZString/Utf16ValueStringBuilder.cs +++ b/src/ZString/Utf16ValueStringBuilder.cs @@ -512,6 +512,9 @@ public bool TryCopyTo(Span destination, out int charsWritten) /// Converts the value of this instance to a System.String. public override string ToString() { + if (index == 0) + return string.Empty; + return new string(buffer, 0, index); } diff --git a/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs b/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs index b04471c..dd58fce 100644 --- a/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs +++ b/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.cs @@ -68,6 +68,10 @@ static object CreateFormatter(Type type) { return new TryFormat((System.Guid x, Span dest, out int written, StandardFormat format) => Utf8Formatter.TryFormat(x, dest, out written, format)); } + if (type == typeof(System.Boolean)) + { + return new TryFormat((System.Boolean x, Span dest, out int written, StandardFormat format) => Utf8Formatter.TryFormat(x, dest, out written, format)); + } if (type == typeof(System.Byte?)) { return CreateNullableFormatter(); @@ -128,6 +132,10 @@ static object CreateFormatter(Type type) { return CreateNullableFormatter(); } + if (type == typeof(System.Boolean?)) + { + return CreateNullableFormatter(); + } if (type == typeof(System.IntPtr)) { // ignore format diff --git a/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt b/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt index 544198d..bddf117 100644 --- a/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt +++ b/src/ZString/Utf8/Utf8ValueStringBuilder.CreateFormatter.tt @@ -15,13 +15,13 @@ namespace Cysharp.Text { static object CreateFormatter(Type type) { -<# foreach(var t in spanFormattables) { #> +<# foreach(var t in utf8spanFormattables) { #> if (type == typeof(<#= t.FullName #>)) { return new TryFormat<<#= t.FullName #>>((<#= t.FullName #> x, Span dest, out int written, StandardFormat format) => Utf8Formatter.TryFormat(x, dest, out written, format)); } <# } #> -<# foreach(var t in spanFormattables) { #> +<# foreach(var t in utf8spanFormattables) { #> if (type == typeof(<#= t.FullName #>?)) { return CreateNullableFormatter<<#= t.FullName #>>(); diff --git a/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs b/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs index 1a46010..5321ecb 100644 --- a/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs +++ b/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.cs @@ -52,6 +52,7 @@ public void AppendLine(System.Byte value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.DateTime value) @@ -97,6 +98,7 @@ public void AppendLine(System.DateTime value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.DateTimeOffset value) @@ -142,6 +144,7 @@ public void AppendLine(System.DateTimeOffset value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Decimal value) @@ -187,6 +190,7 @@ public void AppendLine(System.Decimal value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Double value) @@ -232,6 +236,7 @@ public void AppendLine(System.Double value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Int16 value) @@ -277,6 +282,7 @@ public void AppendLine(System.Int16 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Int32 value) @@ -322,6 +328,7 @@ public void AppendLine(System.Int32 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Int64 value) @@ -367,6 +374,7 @@ public void AppendLine(System.Int64 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.SByte value) @@ -412,6 +420,7 @@ public void AppendLine(System.SByte value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Single value) @@ -457,6 +466,7 @@ public void AppendLine(System.Single value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.TimeSpan value) @@ -502,6 +512,7 @@ public void AppendLine(System.TimeSpan value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.UInt16 value) @@ -547,6 +558,7 @@ public void AppendLine(System.UInt16 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.UInt32 value) @@ -592,6 +604,7 @@ public void AppendLine(System.UInt32 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.UInt64 value) @@ -637,6 +650,7 @@ public void AppendLine(System.UInt64 value, StandardFormat format) Append(value, format); AppendLine(); } + /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(System.Guid value) @@ -682,5 +696,52 @@ public void AppendLine(System.Guid value, StandardFormat format) Append(value, format); AppendLine(); } + + /// Appends the string representation of a specified value to this instance. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Append(System.Boolean value) + { + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written)) + { + Grow(written); + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out written)) + { + ThrowArgumentException(nameof(value)); + } + } + index += written; + } + + /// Appends the string representation of a specified value to this instance with numeric format strings. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Append(System.Boolean value, StandardFormat format) + { + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out var written, format)) + { + Grow(written); + if(!Utf8Formatter.TryFormat(value, buffer.AsSpan(index), out written, format)) + { + ThrowArgumentException(nameof(value)); + } + } + index += written; + } + + /// Appends the string representation of a specified value followed by the default line terminator to the end of this instance. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void AppendLine(System.Boolean value) + { + Append(value); + AppendLine(); + } + + /// Appends the string representation of a specified value with numeric format strings followed by the default line terminator to the end of this instance. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void AppendLine(System.Boolean value, StandardFormat format) + { + Append(value, format); + AppendLine(); + } + } } diff --git a/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt b/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt index 819f211..8596264 100644 --- a/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt +++ b/src/ZString/Utf8/Utf8ValueStringBuilder.SpanFormattableAppend.tt @@ -14,7 +14,7 @@ namespace Cysharp.Text { public partial struct Utf8ValueStringBuilder { -<# foreach(var t in spanFormattables) { #> +<# foreach(var t in utf8spanFormattables) { #> /// Appends the string representation of a specified value to this instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(<#= t.FullName #> value) @@ -60,6 +60,7 @@ namespace Cysharp.Text Append(value, format); AppendLine(); } + <# } #> } } diff --git a/src/ZString/Utf8ValueStringBuilder.cs b/src/ZString/Utf8ValueStringBuilder.cs index 56cfce2..c30b2b2 100644 --- a/src/ZString/Utf8ValueStringBuilder.cs +++ b/src/ZString/Utf8ValueStringBuilder.cs @@ -313,6 +313,9 @@ public Task WriteToAsync(Stream stream) /// Encode the innner utf8 buffer to a System.String. public override string ToString() { + if (index == 0) + return string.Empty; + return UTF8NoBom.GetString(buffer, 0, index); } diff --git a/src/ZString/ZString.Concat.cs b/src/ZString/ZString.Concat.cs index 2ab15f6..b97088b 100644 --- a/src/ZString/ZString.Concat.cs +++ b/src/ZString/ZString.Concat.cs @@ -7,6 +7,11 @@ public static partial class ZString /// Concatenates the string representation of some specified objects. public static string Concat(T1 arg1) { + if (typeof(T1) == typeof(string)) + { + return (arg1 != null) ? Unsafe.As(arg1) : string.Empty; + } + var sb = new Utf16ValueStringBuilder(true); try { diff --git a/src/ZString/ZString.Concat.tt b/src/ZString/ZString.Concat.tt index 4c5f055..7c9f854 100644 --- a/src/ZString/ZString.Concat.tt +++ b/src/ZString/ZString.Concat.tt @@ -15,6 +15,13 @@ namespace Cysharp.Text /// Concatenates the string representation of some specified objects. public static string Concat<<#= CreateTypeArgument(i) #>>(<#= CreateParameters(i) #>) { +<# if(i == 1) { #> + if (typeof(T1) == typeof(string)) + { + return (arg1 != null) ? Unsafe.As(arg1) : string.Empty; + } + +<# } #> var sb = new Utf16ValueStringBuilder(true); try { diff --git a/tests/ZString.Tests/Primitives.cs b/tests/ZString.Tests/Primitives.cs index 1a2ed26..d5145d7 100644 --- a/tests/ZString.Tests/Primitives.cs +++ b/tests/ZString.Tests/Primitives.cs @@ -205,5 +205,29 @@ public void EnumTest() sb1.ToString().Should().Be(sb5.ToString()); } } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void BoolTest(bool x) + { + using (var sb1 = ZString.CreateStringBuilder()) + using (var sb2 = ZString.CreateUtf8StringBuilder()) + using (var sb3 = ZString.CreateStringBuilder()) + using (var sb4 = ZString.CreateUtf8StringBuilder()) + { + var sb5 = new StringBuilder(); + sb1.Append(x); + sb2.Append(x); + sb3.Append(x); + sb4.Append(x); + sb5.Append(x); + + sb1.ToString().Should().Be(sb2.ToString()); + sb1.ToString().Should().Be(sb3.ToString()); + sb1.ToString().Should().Be(sb4.ToString()); + sb1.ToString().Should().Be(sb5.ToString()); + } + } } }