Skip to content

Commit

Permalink
add runes to known safe types
Browse files Browse the repository at this point in the history
  • Loading branch information
lofcz committed Jan 8, 2025
1 parent e526f64 commit b617523
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
46 changes: 46 additions & 0 deletions FastCloner.Tests/SpecialCaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,52 @@ public unsafe void Test_Unnamed_Type()
});
}

[Test]
public void Test_Rune()
{
// Arrange
Rune obj = new Rune(0x1F44D);

// Act
Rune result = obj.DeepClone();

// Assert
Assert.Multiple(() =>
{
Assert.That(result, Is.EqualTo(obj));
Assert.That(result, Is.EqualTo(obj));
Assert.That(result.Value, Is.EqualTo(obj.Value));
Assert.That(result.ToString(), Is.EqualTo("👍"));
});
}

[Test]
public void Test_RuneContainer()
{
// Arrange
RuneContainer container = new RuneContainer
{
// Emoji '🚀' (ROCKET) - Unicode U+1F680
RuneValue = new Rune(0x1F680)
};

// Act
RuneContainer result = container.DeepClone();

// Assert
Assert.Multiple(() =>
{
Assert.That(ReferenceEquals(result, container), Is.False);
Assert.That(result.RuneValue, Is.EqualTo(container.RuneValue));
Assert.That(result.RuneValue.ToString(), Is.EqualTo("🚀"));
});
}

public class RuneContainer
{
public Rune RuneValue { get; set; }
}

[Test]
public void Test_TimeSpan()
{
Expand Down
2 changes: 2 additions & 0 deletions FastCloner/Code/FastClonerSafeTypes.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using System.Reflection;
using System.Text;

namespace FastCloner.Code;

Expand Down Expand Up @@ -28,6 +29,7 @@ internal static class FastClonerSafeTypes
[typeof(nint)] = true,
[typeof(nuint)] = true,
[typeof(Guid)] = true,
[typeof(Rune)] = true,

// Time-related types
[typeof(TimeSpan)] = true,
Expand Down

0 comments on commit b617523

Please sign in to comment.