Skip to content

Commit

Permalink
SecureMemoryTests.cs: Switch to DynamicData and use the PageSize cons…
Browse files Browse the repository at this point in the history
…tant.

Since PageSize depends on the system. This is also consistent with GuardedHeapAllocation_Invalid().
  • Loading branch information
samuel-lucas6 committed Dec 15, 2024
1 parent 9c4ea6b commit 293a61c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Geralt.Tests/SecureMemoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
[TestClass]
public class SecureMemoryTests
{
public static IEnumerable<object[]> InvalidLockMemorySizes()
{
yield return [0];
yield return [SecureMemory.PageSize + 1];
yield return [SecureMemory.PageSize - 1];
yield return [SecureMemory.PageSize * 2 + 1];
yield return [SecureMemory.PageSize * 2 - 1];
}

// With DataRow(), the associated test fails on macOS
public static IEnumerable<object[]> InvalidGuardedHeapAllocationSizes()
{
Expand Down Expand Up @@ -92,11 +101,7 @@ public void LockMemory_UnlockAndZeroMemory_Valid()
}

[TestMethod]
[DataRow(0)]
[DataRow(4096 + 1)]
[DataRow(4096 - 1)]
[DataRow(8192 + 1)]
[DataRow(8192 - 1)]
[DynamicData(nameof(InvalidLockMemorySizes), DynamicDataSourceType.Method)]
public void LockMemory_UnlockAndZeroMemory_Invalid(int bufferSize)
{
var b = new byte[bufferSize];
Expand Down

0 comments on commit 293a61c

Please sign in to comment.