Fix ReadOnlySpanGetReferenceAndReadInteger on BigEndian (#85969)
authorEgor Bogatov <egorbo@gmail.com>
Tue, 9 May 2023 14:25:01 +0000 (16:25 +0200)
committerGitHub <noreply@github.com>
Tue, 9 May 2023 14:25:01 +0000 (16:25 +0200)
src/libraries/System.Memory/tests/MemoryMarshal/GetReference.cs

index d0e83a0..9760c88 100644 (file)
@@ -104,11 +104,15 @@ namespace System.SpanTests
         [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)));
         }