Skip to content

Commit

Permalink
Added test for Swap (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Oct 16, 2023
1 parent 1580c16 commit 3654cc9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DotNext.Tests/SpanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,12 @@ public static void SplitSpanByLength()
Equal(chars.ToString(), head.ToString());
Equal(string.Empty, rest.ToString());
}

[Fact]
public static void SwapElements()
{
Span<int> 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());
}
}

0 comments on commit 3654cc9

Please sign in to comment.