Skip to content

Commit 53e9c0d

Browse files
committed
Code cleanup
1 parent efc51ae commit 53e9c0d

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

src/DotNext.Tests/Buffers/MemoryOwnerTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ public static void WrapArray()
6666
Equal(10, array[2]);
6767
}
6868

69-
public static TheoryData<MemoryAllocator<int>> GetArrayAllocators() => new()
70-
{
69+
public static TheoryData<MemoryAllocator<int>> GetArrayAllocators() =>
70+
[
7171
Memory.GetArrayAllocator<int>(),
7272
Memory.GetPinnedArrayAllocator<int>(),
73-
};
73+
UnmanagedMemory.GetAllocator<int>(zeroMem: false),
74+
UnmanagedMemory.GetAllocator<int>(zeroMem: true)
75+
];
7476

7577
[Theory]
7678
[MemberData(nameof(GetArrayAllocators))]

src/DotNext.Tests/Buffers/UnmanagedMemoryPoolTests.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public static void ReadWriteTest()
2929
}
3030

3131
[Fact]
32-
public static unsafe void ArrayInteropTest()
32+
public static void ArrayInteropTest()
3333
{
3434
using var owner = UnmanagedMemory.Allocate<ushort>(3);
35-
Span<ushort> array = owner.Span;
35+
var array = owner.Span;
3636
array[0] = 10;
3737
array[1] = 20;
3838
array[2] = 30;
@@ -47,22 +47,6 @@ public static unsafe void ArrayInteropTest()
4747
Equal(100, array[0]);
4848
}
4949

50-
[Fact]
51-
public static unsafe void UnmanagedMemoryAllocation()
52-
{
53-
using var owner = UnmanagedMemory.GetAllocator<ushort>(false).Invoke(3);
54-
Span<ushort> array = owner.Span;
55-
array[0] = 10;
56-
array[1] = 20;
57-
array[2] = 30;
58-
59-
var dest = new ushort[array.Length];
60-
array.CopyTo(dest);
61-
Equal(10, dest[0]);
62-
Equal(20, dest[1]);
63-
Equal(30, dest[2]);
64-
}
65-
6650
[Fact]
6751
public static void ResizeTest()
6852
{
@@ -160,7 +144,7 @@ public static void EnumeratorTest()
160144
}
161145

162146
[Fact]
163-
public static unsafe void ZeroMem()
147+
public static void ZeroMem()
164148
{
165149
using var memory = UnmanagedMemory.Allocate<byte>(3);
166150
memory.Span[0] = 10;
@@ -195,7 +179,7 @@ public static void StreamInterop()
195179
}
196180

197181
[Fact]
198-
public static unsafe void ToStreamConversion()
182+
public static void ToStreamConversion()
199183
{
200184
using var memory = UnmanagedMemory.AllocateZeroed<byte>(3);
201185
new byte[] { 10, 20, 30 }.AsSpan().CopyTo(memory.Bytes);

0 commit comments

Comments
 (0)