From 09c37b6d08a6c479e3e361076bb2f5b5a6a8859b Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Wed, 3 Apr 2024 09:35:56 -0500 Subject: [PATCH] Move tests. --- .../Text/MUTF8EncodingTests.cs | 11 -------- .../MemoryMarshalExtensionsTests.cs | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 src/IKVM.Tests/Runtime/Extensions/MemoryMarshalExtensionsTests.cs diff --git a/src/IKVM.ByteCode.Tests/Text/MUTF8EncodingTests.cs b/src/IKVM.ByteCode.Tests/Text/MUTF8EncodingTests.cs index ea79075aab..1b297c7227 100644 --- a/src/IKVM.ByteCode.Tests/Text/MUTF8EncodingTests.cs +++ b/src/IKVM.ByteCode.Tests/Text/MUTF8EncodingTests.cs @@ -53,17 +53,6 @@ public void CanDecodeNullByte() s[0].Should().Be('\0'); } - [TestMethod] - public unsafe void CanFindNullByte() - { - fixed (byte* ptr = new byte[] { 0x01, 0x00 }) - MUTF8Encoding.GetMUTF8(48).IndexOfNull(ptr).Should().Be(1); - fixed (byte* ptr = new byte[] { 0x00, 0x00 }) - MUTF8Encoding.GetMUTF8(48).IndexOfNull(ptr).Should().Be(0); - fixed (byte* ptr = new byte[] { 0x01, 0x01, 0x00 }) - MUTF8Encoding.GetMUTF8(48).IndexOfNull(ptr).Should().Be(2); - } - [TestMethod] public void CanEncodeNull() { diff --git a/src/IKVM.Tests/Runtime/Extensions/MemoryMarshalExtensionsTests.cs b/src/IKVM.Tests/Runtime/Extensions/MemoryMarshalExtensionsTests.cs new file mode 100644 index 0000000000..4e7df4d7f2 --- /dev/null +++ b/src/IKVM.Tests/Runtime/Extensions/MemoryMarshalExtensionsTests.cs @@ -0,0 +1,27 @@ +using FluentAssertions; + +using IKVM.Runtime.Extensions; + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace IKVM.Tests.Runtime.Extensions +{ + + [TestClass] + public class MemoryMarshalExtensionsTests + { + + [TestMethod] + public unsafe void CanFindNullByte() + { + fixed (byte* ptr = new byte[] { 0x01, 0x00 }) + MemoryMarshalExtensions.GetIndexOfNull(ptr).Should().Be(1); + fixed (byte* ptr = new byte[] { 0x00, 0x00 }) + MemoryMarshalExtensions.GetIndexOfNull(ptr).Should().Be(0); + fixed (byte* ptr = new byte[] { 0x01, 0x01, 0x00 }) + MemoryMarshalExtensions.GetIndexOfNull(ptr).Should().Be(2); + } + + } + +}