public static void ComputeHashCodeInt32ArrayInt32Int32Int32Test() { Assert.That(() => HashUtilities.ComputeHashCode(null as int[], 0, 0, 0), Throws.InstanceOf <ArgumentNullException>() .With.Property("ParamName").EqualTo("values") ); Assert.That(() => HashUtilities.ComputeHashCode(Array.Empty <int>(), -1, 0, 0), Throws.InstanceOf <ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("offset") .And.With.Property("ActualValue").EqualTo(-1) ); Assert.That(() => HashUtilities.ComputeHashCode(Array.Empty <int>(), 1, 0, 0), Throws.InstanceOf <ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("offset") .And.With.Property("ActualValue").EqualTo(1) ); Assert.That(() => HashUtilities.ComputeHashCode(Array.Empty <int>(), 0, -1, 0), Throws.InstanceOf <ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("count") .And.With.Property("ActualValue").EqualTo(-1) ); Assert.That(() => HashUtilities.ComputeHashCode(Array.Empty <int>(), 0, 1, 0), Throws.InstanceOf <ArgumentOutOfRangeException>() .With.Property("ParamName").EqualTo("count") .And.With.Property("ActualValue").EqualTo(1) ); Assert.That(HashUtilities.ComputeHashCode(Array.Empty <int>(), 0, 0, 0), Is.EqualTo(0) ); }
public static void Murmur3SanityTest() { var key = new byte[256]; var hashes = new int[256]; for (var index = 0; index < 256; index++) { key[index] = (byte)(index); hashes[index] = HashUtilities.ComputeHashCode(key, 0, index, (256 - index)); } Assert.That(HashUtilities.ComputeHashCode(hashes, 0, hashes.Length, 0), Is.EqualTo(-1326088477) ); }