diff --git a/tests/SharpArena.Tests/Collections/ArenaUtfStringTests.cs b/tests/SharpArena.Tests/Collections/ArenaUtfStringTests.cs index 033733b..bc7ab37 100644 --- a/tests/SharpArena.Tests/Collections/ArenaUtfStringTests.cs +++ b/tests/SharpArena.Tests/Collections/ArenaUtfStringTests.cs @@ -47,6 +47,34 @@ public void ArenaUtf16String_ToUtf8_EncodesCorrectly() utf8.Length.Should().Be(System.Text.Encoding.UTF8.GetByteCount(text)); } + [Fact] + public void ArenaUtf8String_DecodeTo_DecodesCorrectly() + { + var text = "Hello DecodeTo!"; + var bytes = System.Text.Encoding.UTF8.GetBytes(text); + var utf8String = ArenaUtf8String.Clone(bytes, _arena); + + var destination = new char[text.Length]; + var decodedLength = utf8String.DecodeTo(destination); + + decodedLength.Should().Be(text.Length); + new string(destination).Should().Be(text); + } + + [Fact] + public void ArenaUtf8String_DecodeTo_WithEmojis() + { + var text = "Hello DecodeTo! 😊"; + var bytes = System.Text.Encoding.UTF8.GetBytes(text); + var utf8String = ArenaUtf8String.Clone(bytes, _arena); + + var destination = new char[text.Length]; + var decodedLength = utf8String.DecodeTo(destination); + + decodedLength.Should().Be(text.Length); + new string(destination).Should().Be(text); + } + [Fact] public void ArenaUtf8String_GetHashCode_IsContentBased() {