Skip to content

Commit 76f8c9e

Browse files
committed
Add MemoryOwnerTest
1 parent fc439c6 commit 76f8c9e

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using CommunityToolkit.HighPerformance.Buffers;
2+
3+
namespace MemoryModelTest;
4+
5+
public static class MemoryOwnerTest
6+
{
7+
8+
#region Constants & Statics
9+
10+
public static void SliceTest()
11+
{
12+
using var buffer = MemoryOwner<int>.Allocate(42);
13+
if (buffer.Length > 50)
14+
{
15+
using var buffer2 = buffer[..50];
16+
17+
var span = buffer2.Span;
18+
span[0] = 123;
19+
}
20+
}
21+
22+
#endregion
23+
24+
}

src/Tests/MemoryModelTest/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public static void Main(string[] args)
3030

3131
//ArrayBufferWriterTest.Test();
3232

33-
ArrayPoolBufferWriterTest.Test();
33+
//ArrayPoolBufferWriterTest.Test();
34+
35+
//MemoryOwnerTest.SliceTest();
36+
37+
SpanOwnerTest.Test();
3438
}
3539

3640
#endregion
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using CommunityToolkit.HighPerformance.Buffers;
2+
3+
namespace MemoryModelTest;
4+
5+
public static class SpanOwnerTest
6+
{
7+
8+
#region Constants & Statics
9+
10+
public static void Test()
11+
{
12+
using var buffer = SpanOwner<int>.Allocate(100);
13+
14+
var span = buffer.Span;
15+
}
16+
17+
#endregion
18+
19+
}

0 commit comments

Comments
 (0)