Fix FindFirstEqualByte tests
- On some platforms, the bytes array was not large enough to fill a vector. Ex: https://travis-ci.org/aspnet/KestrelHttpServer/builds/105277870#L2633 - Additionally test FindFirstEqualByte with only one bit set in the array
This commit is contained in:
parent
15ed03eb26
commit
d616f0ccb0
|
|
@ -21,31 +21,43 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void FindFirstByte()
|
||||
public void FindFirstEqualByte()
|
||||
{
|
||||
var bytes = new byte[] {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
var bytes = Enumerable.Repeat<byte>(0xff, Vector<byte>.Count).ToArray();
|
||||
for (int i = 0; i < Vector<byte>.Count; i++)
|
||||
{
|
||||
Vector<byte> vector = new Vector<byte>(bytes);
|
||||
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByte(ref vector));
|
||||
bytes[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Vector<byte>.Count; i++)
|
||||
{
|
||||
bytes[i] = 1;
|
||||
Vector<byte> vector = new Vector<byte>(bytes);
|
||||
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByte(ref vector));
|
||||
bytes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void _FindFirstByte()
|
||||
public void FindFirstEqualByteSlow()
|
||||
{
|
||||
var bytes = new byte[] {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
var bytes = Enumerable.Repeat<byte>(0xff, Vector<byte>.Count).ToArray();
|
||||
for (int i = 0; i < Vector<byte>.Count; i++)
|
||||
{
|
||||
Vector<byte> vector = new Vector<byte>(bytes);
|
||||
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByteSlow(ref vector));
|
||||
bytes[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Vector<byte>.Count; i++)
|
||||
{
|
||||
bytes[i] = 1;
|
||||
Vector<byte> vector = new Vector<byte>(bytes);
|
||||
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByteSlow(ref vector));
|
||||
bytes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
|||
Loading…
Reference in New Issue