diff options
author | dotnet bot <dotnet-bot@dotnetfoundation.org> | 2018-03-29 06:22:38 +0300 |
---|---|---|
committer | Ahson Khan <ahkha@microsoft.com> | 2018-03-29 06:22:38 +0300 |
commit | bb5c46859048bfcefca281d7c303540c1217da41 (patch) | |
tree | 0364eacd3d965776f59fede61ceb601e353a8ba5 /src/System.Memory/tests/Memory/Retain.cs | |
parent | 52bdd078870fb3b10ed050b0bc40391e90c9c6b0 (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.cs | 48 |
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(); - } } } |