Skip to content

Commit

Permalink
[tests] Fix recently added mono test (#110682)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrzVlad authored Dec 16, 2024
1 parent 373f048 commit e9c95f4
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct BigArray_64_1
{
}

[StructLayout(LayoutKind.Sequential, Size = int.MaxValue - 16 - 1)]
[StructLayout(LayoutKind.Sequential, Size = int.MaxValue - 16 + 1)]
struct BigArray_64_2
{
}
Expand All @@ -65,29 +65,39 @@ struct BigArray_32_1
{
}

[StructLayout(LayoutKind.Sequential, Size = int.MaxValue - 8 - 1)]
[StructLayout(LayoutKind.Sequential, Size = int.MaxValue - 8 + 1)]
struct BigArray_32_2
{
}

[Fact]
public static void TestLargeStructSize()
public static void Test64Bit ()
{
if (Environment.Is64BitProcess)
{
Assert.Equal(int.MaxValue - (IntPtr.Size * 2), sizeof(BigArray_64_1));
Assert.Throws<TypeLoadException>(() => sizeof(BigArray_64_2));
Assert.Throws<TypeLoadException>(() => sizeof(X_64));
Assert.Throws<TypeLoadException>(() => sizeof(X_explicit_64));
Assert.Throws<TypeLoadException>(() => sizeof(Y_64));
}
else
{
}

public static void Test32Bit ()
{
Assert.Equal(int.MaxValue - (IntPtr.Size * 2), sizeof(BigArray_32_1));
Assert.Throws<TypeLoadException>(() => sizeof(BigArray_32_2));
Assert.Throws<TypeLoadException>(() => sizeof(X_32));
Assert.Throws<TypeLoadException>(() => sizeof(X_explicit_32));
Assert.Throws<TypeLoadException>(() => sizeof(Y_32));
}

[Fact]
public static void TestLargeStructSize()
{
if (Environment.Is64BitProcess)
{
Test64Bit ();
}
else
{
Test32Bit ();
}
}
}

0 comments on commit e9c95f4

Please sign in to comment.