Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/SharpArena.Tests/Collections/ArenaUtfStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Loading