Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.byte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,30 @@ public static void LengthMismatchSequenceCompareTo_Byte()
Assert.True(result > 0);
}

[Fact]
public static void SequenceCompareToEqual_Byte()
{
for (int length = 1; length < 128; length++)
{
var first = new byte[length];
var second = new byte[length];
for (int i = 0; i < length; i++)
{
first[i] = second[i] = (byte)(i + 1);
}

var firstSpan = new ReadOnlySpan<byte>(first);
var secondSpan = new ReadOnlySpan<byte>(second);

Assert.Equal(0, firstSpan.SequenceCompareTo<byte>(secondSpan));
Assert.Equal(0, secondSpan.SequenceCompareTo<byte>(firstSpan));
}
}

[Fact]
public static void SequenceCompareToWithSingleMismatch_Byte()
{
for (int length = 1; length < 32; length++)
for (int length = 1; length < 128; length++)
{
for (int mismatchIndex = 0; mismatchIndex < length; mismatchIndex++)
{
Expand All @@ -101,7 +121,7 @@ public static void SequenceCompareToWithSingleMismatch_Byte()
[Fact]
public static void SequenceCompareToNoMatch_Byte()
{
for (int length = 1; length < 32; length++)
for (int length = 1; length < 128; length++)
{
var first = new byte[length];
var second = new byte[length];
Expand Down
24 changes: 22 additions & 2 deletions src/System.Memory/tests/Span/SequenceCompareTo.byte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,30 @@ public static void LengthMismatchSequenceCompareTo_Byte()
Assert.True(result > 0);
}

[Fact]
public static void SequenceCompareToEqual_Byte()
{
for (int length = 1; length < 128; length++)
{
var first = new byte[length];
var second = new byte[length];
for (int i = 0; i < length; i++)
{
first[i] = second[i] = (byte)(i + 1);
}

var firstSpan = new Span<byte>(first);
var secondSpan = new Span<byte>(second);

Assert.Equal(0, firstSpan.SequenceCompareTo<byte>(secondSpan));
Assert.Equal(0, secondSpan.SequenceCompareTo<byte>(firstSpan));
}
}

[Fact]
public static void SequenceCompareToWithSingleMismatch_Byte()
{
for (int length = 1; length < 32; length++)
for (int length = 1; length < 128; length++)
{
for (int mismatchIndex = 0; mismatchIndex < length; mismatchIndex++)
{
Expand All @@ -101,7 +121,7 @@ public static void SequenceCompareToWithSingleMismatch_Byte()
[Fact]
public static void SequenceCompareToNoMatch_Byte()
{
for (int length = 1; length < 32; length++)
for (int length = 1; length < 128; length++)
{
byte[] first = new byte[length];
byte[] second = new byte[length];
Expand Down