Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotnet bot <dotnet-bot@dotnetfoundation.org>2018-03-29 06:22:38 +0300
committerAhson Khan <ahkha@microsoft.com>2018-03-29 06:22:38 +0300
commitbb5c46859048bfcefca281d7c303540c1217da41 (patch)
tree0364eacd3d965776f59fede61ceb601e353a8ba5 /src/System.Memory/tests/Memory/Retain.cs
parent52bdd078870fb3b10ed050b0bc40391e90c9c6b0 (diff)
Mirror changes from dotnet/coreclr (#28534)
* Adding Memory.Pin() to eventually replace Memory.Retain(bool) (#17269) * Adding Memory.Pin() to eventually replace Memory.Retain(bool) * Fix copy/paste error and return default for when object is null. * Fix XML comments. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com> * Add Memory.Pin to the ref and add tests. * Add Pin tests * Update calls to Retain(true) to now call Pin() * Remove extra space in tests. * Add Pin to the ApiCompatBaseline for uapaot.
Diffstat (limited to 'src/System.Memory/tests/Memory/Retain.cs')
-rw-r--r--src/System.Memory/tests/Memory/Retain.cs48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/System.Memory/tests/Memory/Retain.cs b/src/System.Memory/tests/Memory/Retain.cs
index 3a33817dff..1ef319103c 100644
--- a/src/System.Memory/tests/Memory/Retain.cs
+++ b/src/System.Memory/tests/Memory/Retain.cs
@@ -46,6 +46,30 @@ namespace System.MemoryTests
}
[Fact]
+ public static void MemoryFromEmptyArrayRetainWithPinning()
+ {
+ Memory<int> memory = new int[0];
+ MemoryHandle handle = memory.Retain(pin: true);
+ Assert.True(handle.HasPointer);
+ handle.Dispose();
+ }
+
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public static void DefaultMemoryRetain(bool pin)
+ {
+ Memory<int> memory = default;
+ MemoryHandle handle = memory.Retain(pin: pin);
+ Assert.False(handle.HasPointer);
+ unsafe
+ {
+ Assert.True(handle.Pointer == null);
+ }
+ handle.Dispose();
+ }
+
+ [Fact]
public static void MemoryRetainWithPinningAndSlice()
{
int[] array = { 1, 2, 3, 4, 5 };
@@ -111,15 +135,6 @@ namespace System.MemoryTests
}
[Fact]
- public static void MemoryFromEmptyArrayRetainWithPinning()
- {
- Memory<int> memory = new int[0];
- MemoryHandle handle = memory.Retain(pin: true);
- Assert.True(handle.HasPointer);
- handle.Dispose();
- }
-
- [Fact]
public static void OwnedMemoryRetainWithPinningAndSlice()
{
int[] array = { 1, 2, 3, 4, 5 };
@@ -146,20 +161,5 @@ namespace System.MemoryTests
}
handle.Dispose();
}
-
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public static void DefaultMemoryRetain(bool pin)
- {
- Memory<int> memory = default;
- MemoryHandle handle = memory.Retain(pin: pin);
- Assert.False(handle.HasPointer);
- unsafe
- {
- Assert.True(handle.Pointer == null);
- }
- handle.Dispose();
- }
}
}