diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-06-16 17:44:57 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-10-30 17:27:27 -0700 |
commit | 9c7c1b741b132cd78bfc9db2654227bc2aec2e45 (patch) | |
tree | 3cead576af5ff1396e10cf2792b7e318ab86a766 /tests/src/CoreMangLib/system | |
parent | 24a8d61949640fe73c4046b1cf710fb3137ef367 (diff) | |
download | coreclr-9c7c1b741b132cd78bfc9db2654227bc2aec2e45.tar.gz coreclr-9c7c1b741b132cd78bfc9db2654227bc2aec2e45.tar.bz2 coreclr-9c7c1b741b132cd78bfc9db2654227bc2aec2e45.zip |
Add basic Span<T> test
Diffstat (limited to 'tests/src/CoreMangLib/system')
-rw-r--r-- | tests/src/CoreMangLib/system/span/BasicSpanTest.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/src/CoreMangLib/system/span/BasicSpanTest.cs b/tests/src/CoreMangLib/system/span/BasicSpanTest.cs new file mode 100644 index 0000000000..c7c9618b9a --- /dev/null +++ b/tests/src/CoreMangLib/system/span/BasicSpanTest.cs @@ -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()); + } +} |