Beispiel #1
0
        public void CheckReferenceResultsUnsafe()
        {
            unsafe
            {
                fixed(byte *ptr = _testData)
                {
                    //DJBHash32
                    uint r1 = DJBHash32Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt32(_testResults[typeof(DJBHash32)], 0), r1);

                    //Farmhash32
                    uint r2 = FarmHash32Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt32(_testResults[typeof(FarmHash32)], 0), r2);

                    //Farmhash64
                    ulong r3 = FarmHash64Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt64(_testResults[typeof(FarmHash64)], 0), r3);

                    //FNV1A32
                    uint r4 = FNV1A32Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt32(_testResults[typeof(FNV1A32)], 0), r4);

                    //MurmurHash32
                    uint r5 = MurmurHash32Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt32(_testResults[typeof(MurmurHash32)], 0), r5);

                    //MurmurHash128
                    byte[] r6 = MurmurHash128Unsafe.ComputeHash(ptr, _testData.Length);
                    Assert.True(_testResults[typeof(MurmurHash128)].SequenceEqual(r6));

                    //SipHash64
                    ulong r7 = SipHash64Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt64(_testResults[typeof(SipHash64)], 0), r7);

                    //SuperFastHash32
                    uint r8 = SuperFastHash32Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt32(_testResults[typeof(SuperFastHash32)], 0), r8);

                    //xxHash32
                    uint r9 = xxHash32Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt32(_testResults[typeof(xxHash32)], 0), r9);

                    //xxHash64
                    ulong r10 = xxHash64Unsafe.ComputeHash(ptr, _testData.Length);

                    Assert.Equal(BitConverter.ToUInt64(_testResults[typeof(xxHash64)], 0), r10);
                }
            }
        }
Beispiel #2
0
 public unsafe uint Farmhash32UnsafeTest()
 {
     return(FarmHash32Unsafe.ComputeHash(_unsafePtr, _testData.Length));
 }