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]
|
[Fact]
|
||||||
public void FindFirstByte()
|
public void FindFirstEqualByte()
|
||||||
{
|
{
|
||||||
var bytes = new byte[] {
|
var bytes = Enumerable.Repeat<byte>(0xff, Vector<byte>.Count).ToArray();
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
|
||||||
for (int i = 0; i < Vector<byte>.Count; i++)
|
for (int i = 0; i < Vector<byte>.Count; i++)
|
||||||
{
|
{
|
||||||
Vector<byte> vector = new Vector<byte>(bytes);
|
Vector<byte> vector = new Vector<byte>(bytes);
|
||||||
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByte(ref vector));
|
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByte(ref vector));
|
||||||
bytes[i] = 0;
|
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]
|
[Fact]
|
||||||
public void _FindFirstByte()
|
public void FindFirstEqualByteSlow()
|
||||||
{
|
{
|
||||||
var bytes = new byte[] {
|
var bytes = Enumerable.Repeat<byte>(0xff, Vector<byte>.Count).ToArray();
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
|
||||||
for (int i = 0; i < Vector<byte>.Count; i++)
|
for (int i = 0; i < Vector<byte>.Count; i++)
|
||||||
{
|
{
|
||||||
Vector<byte> vector = new Vector<byte>(bytes);
|
Vector<byte> vector = new Vector<byte>(bytes);
|
||||||
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByteSlow(ref vector));
|
Assert.Equal(i, MemoryPoolIterator2.FindFirstEqualByteSlow(ref vector));
|
||||||
bytes[i] = 0;
|
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]
|
[Theory]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue