public void Test_2_4()
{
var key = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
var k0 = BitConverter.ToUInt64(key, 0);
var k1 = BitConverter.ToUInt64(key, 8);
var maxlen = _vectors.Length;
foreach (
var f in
new Func<byte[], ulong, ulong, ulong>[]
{
SipHash.SipHash_2_4,
SipHash.SipHash_2_4_UlongCast,
SipHash.SipHash_2_4_UlongCast_ForcedInline,
SipHash.SipHash_2_4_ForcedInline
}
)
{
var ok = true;
for (var i = 0; i < maxlen; ++i)
{
var inba = new byte[i];
for (var j = 0; j < i; ++j) inba[j] = (byte) j;
var hash = f(inba, k0, k1);
var hashBytes = BitConverter.GetBytes(hash);
var expected = _vectors[i];
for (var j = 0; j < expected.Length; ++j)
if (expected[j] != hashBytes[j])
{
Debug.WriteLine("fail at vector[{0}][{1}]", i, j);
ok = false;
}
}
Assert.IsTrue(ok);
}
}