Add basic Span<T> test
authorJan Kotas <jkotas@microsoft.com>
Fri, 17 Jun 2016 00:44:57 +0000 (17:44 -0700)
committerJan Kotas <jkotas@microsoft.com>
Mon, 31 Oct 2016 00:27:27 +0000 (17:27 -0700)
tests/src/CoreMangLib/system/span/BasicSpanTest.cs [new file with mode: 0644]

diff --git a/tests/src/CoreMangLib/system/span/BasicSpanTest.cs b/tests/src/CoreMangLib/system/span/BasicSpanTest.cs
new file mode 100644 (file)
index 0000000..c7c9618
--- /dev/null
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+
+class My
+{
+    static int Sum(Span<int> span)
+    {
+        int sum = 0;
+        for (int i = 0; i < span.Length; i++)
+            sum += span[i];
+        return sum;
+    }
+
+    static void Main()
+    {
+        int[] a = new int[] { 1, 2, 3 };
+        Span<int> span = new Span<int>(a);
+        Console.WriteLine(Sum(span).ToString());
+        Span<int> slice = span.Slice(1, 2);
+        Console.WriteLine(Sum(slice).ToString());
+    }
+}