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:
authorAhson Khan <ahkha@microsoft.com>2018-04-10 08:00:13 +0300
committerGitHub <noreply@github.com>2018-04-10 08:00:13 +0300
commit1dfe097dc0201564e61461731058569a20517183 (patch)
tree19bc8eca1424040470d659ed4c8202c601be6a6a /src/System.Memory/tests/Memory/Span.cs
parent14f5d53b9b9badd9402a9331b9f1b8cbd30b5c85 (diff)
Fix MemoryManager ctor, add unit and perf tests, and improve performance (#28880)
* Fix MemoryManager ctor, add unit and perf tests, and improve performance. * Remove Dangerous Span Ctor * Fix sort order in csproj and rename Perf.MemorySlice.cs to Perf.Memory.Slice * Fix MemoryManager ctor and use internal span ctor to improve performance (#17452) * Fix MemoryManager ctor, add unit and perf tests, and use internal span ctor. * Address PR feedback (remove use of Unsafe.As and Dangerous Span Ctor) Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Diffstat (limited to 'src/System.Memory/tests/Memory/Span.cs')
-rw-r--r--src/System.Memory/tests/Memory/Span.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/System.Memory/tests/Memory/Span.cs b/src/System.Memory/tests/Memory/Span.cs
index 55ed001b3d..55956dd6ab 100644
--- a/src/System.Memory/tests/Memory/Span.cs
+++ b/src/System.Memory/tests/Memory/Span.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Buffers;
+using System.Runtime.InteropServices;
using Xunit;
namespace System.MemoryTests
@@ -42,6 +43,22 @@ namespace System.MemoryTests
}
[Fact]
+ public static void SpanFromCtorArrayChar()
+ {
+ char[] a = { '1', '2', '3', '4', '-' };
+ Memory<char> memory;
+
+ memory = new Memory<char>(a);
+ memory.Span.Validate('1', '2', '3', '4', '-');
+
+ memory = new Memory<char>(a, 0, a.Length);
+ memory.Span.Validate('1', '2', '3', '4', '-');
+
+ MemoryManager<char> manager = new CustomMemoryForTest<char>(a);
+ manager.Memory.Span.Validate('1', '2', '3', '4', '-');
+ }
+
+ [Fact]
public static void SpanFromCtorArrayObject()
{
object o1 = new object();
@@ -60,6 +77,19 @@ namespace System.MemoryTests
}
[Fact]
+ public static void SpanFromStringAsMemory()
+ {
+ string a = "1234-";
+ ReadOnlyMemory<char> memory;
+
+ memory = a.AsMemory();
+ MemoryMarshal.AsMemory(memory).Span.Validate('1', '2', '3', '4', '-');
+
+ memory = a.AsMemory(0, a.Length);
+ MemoryMarshal.AsMemory(memory).Span.Validate('1', '2', '3', '4', '-');
+ }
+
+ [Fact]
public static void SpanFromCtorArrayZeroLength()
{
int[] empty = Array.Empty<int>();