From 3654cc96c3765c94db4e55a4ed6632e6804be73e Mon Sep 17 00:00:00 2001 From: sakno Date: Mon, 16 Oct 2023 11:25:24 +0300 Subject: [PATCH] Added test for Swap (#193) --- src/DotNext.Tests/SpanTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/DotNext.Tests/SpanTests.cs b/src/DotNext.Tests/SpanTests.cs index 9e4cfaa82..152137067 100644 --- a/src/DotNext.Tests/SpanTests.cs +++ b/src/DotNext.Tests/SpanTests.cs @@ -518,4 +518,12 @@ public static void SplitSpanByLength() Equal(chars.ToString(), head.ToString()); Equal(string.Empty, rest.ToString()); } + + [Fact] + public static void SwapElements() + { + Span array = stackalloc int[] { 1, 2, 3, 4, 5, 6 }; + array[0..3].Swap(array[3..6]); + Equal(new int[] { 4, 5, 6, 1, 2, 3 }, array.ToArray()); + } } \ No newline at end of file