-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code cleanup, improve Windows and Wine version fetching (#61)
* Code cleanup, improve Windows and Wine version fetching * Improve obsolete test * Return to pool, format
- Loading branch information
1 parent
460ece5
commit e07d03f
Showing
25 changed files
with
1,366 additions
and
1,305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace NorthwoodLib.Tests | ||
namespace NorthwoodLib.Tests; | ||
|
||
public unsafe class NativeMemoryTest | ||
{ | ||
public class NativeMemoryTest | ||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(10)] | ||
[InlineData(16384)] | ||
public void CreateTest(int size) | ||
{ | ||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(10)] | ||
[InlineData(16384)] | ||
public void CreateTest(int size) | ||
using (NativeMemory memory = new(size)) | ||
{ | ||
using (NativeMemory memory = new(size)) | ||
{ | ||
Assert.NotEqual(IntPtr.Zero, memory.Data); | ||
Assert.Equal(size, memory.Length); | ||
} | ||
Assert.NotEqual(nuint.Zero, (nuint)memory.Data); | ||
Assert.Equal(size, memory.Length); | ||
} | ||
} | ||
|
||
[Fact] | ||
public unsafe void AccessTest() | ||
[Fact] | ||
public void AccessTest() | ||
{ | ||
using (NativeMemory memory = new(sizeof(int) * 10)) | ||
{ | ||
using (NativeMemory memory = new(sizeof(int) * 10)) | ||
{ | ||
int* ptr = memory.ToPointer<int>(); | ||
for (int i = 0; i < 10; i++) | ||
ptr[i] = i; | ||
int* ptr = memory.ToPointer<int>(); | ||
for (int i = 0; i < 10; i++) | ||
ptr[i] = i; | ||
|
||
for (int i = 0; i < 10; i++) | ||
Assert.Equal(i, ptr[i]); | ||
} | ||
for (int i = 0; i < 10; i++) | ||
Assert.Equal(i, ptr[i]); | ||
} | ||
} | ||
|
||
[Fact] | ||
public unsafe void PointerTest() | ||
{ | ||
using (NativeMemory memory = new(sizeof(int) * 10)) | ||
Assert.Equal(memory.Data, new IntPtr(memory.ToPointer<int>())); | ||
} | ||
[Fact] | ||
public void PointerTest() | ||
{ | ||
using (NativeMemory memory = new(sizeof(int) * 10)) | ||
Assert.Equal((nuint)memory.Data, (nuint)memory.ToPointer<int>()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.