From 88a28ea8044a6ef0cf9a5a38677b3c9970f40548 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 20 Jun 2026 19:08:17 +0000 Subject: [PATCH] test: add coverage for ArenaUtf8String.DecodeTo Co-authored-by: myarichuk <1473701+myarichuk@users.noreply.github.com> --- .../Collections/ArenaUtfStringTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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() {