From 9c7c1b741b132cd78bfc9db2654227bc2aec2e45 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 16 Jun 2016 17:44:57 -0700 Subject: [PATCH] Add basic Span test --- .../CoreMangLib/system/span/BasicSpanTest.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/src/CoreMangLib/system/span/BasicSpanTest.cs 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 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 span = new Span(a); + Console.WriteLine(Sum(span).ToString()); + Span slice = span.Slice(1, 2); + Console.WriteLine(Sum(slice).ToString()); + } +} -- 2.34.1