Skip to content

Commit

Permalink
Fix ReadOnlySpanGetReferenceAndReadInteger on BigEndian (#85969)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored May 9, 2023
1 parent b212d5c commit dd3a027
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/libraries/System.Memory/tests/MemoryMarshal/GetReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ public static void ReadOnlySpanGetReferenceEmpty()
[Fact]
public static void ReadOnlySpanGetReferenceAndReadInteger()
{
Assert.Equal(6619240,
Assert.Equal(BitConverter.IsLittleEndian ?
0x65_00_68 :
0x68_00_65,
Unsafe.As<byte, int>(ref Unsafe.Add(ref Unsafe.As<char, byte>(
ref MemoryMarshal.GetReference("hello world 1".AsSpan())), 0)));
ref MemoryMarshal.GetReference("hello world 1".AsSpan())), 0)));

Assert.Equal(7998511687277765888,
Assert.Equal(BitConverter.IsLittleEndian ?
0x6F_00_6C_00_6C_00_65_00 :
0x00_65_00_6C_00_6C_00_6F,
Unsafe.As<byte, long>(ref Unsafe.Add(ref Unsafe.As<char, byte>(
ref MemoryMarshal.GetReference("hello world 2".AsSpan())), 1)));
}
Expand Down

0 comments on commit dd3a027

Please sign in to comment.