Exemple #1
0
 public unsafe void RehashULong()
 {
     foreach (ulong seed in RandomUlongs(RandomCycleCount))
     {
         foreach (ulong message in RandomUlongs(RandomCycleCount))
         {
             ulong  copy = message;
             ulong *p    = ©
             Assert.Equal(SpookyHash.Hash64(p, 8, seed), message.Rehash(seed));
         }
     }
     foreach (ulong message in RandomUlongs(RandomCycleCount))
     {
         ulong  copy = message;
         ulong *p    = ©
         Assert.Equal(SpookyHash.Hash64(p, 8, 0xDEADBEEFDEADBEEF), message.Rehash());
     }
 }
Exemple #2
0
        public unsafe void Hash64PtrOverloads()
        {
            ulong  seed       = 238929482;
            string testString = "This is a test string";

            fixed(void *ptr = testString)
            {
                int   len = testString.Length * 2;
                ulong hc  = SpookyHash.Hash64(ptr, len, seed);

                Assert.Equal(hc, SpookyHash.Hash64((UIntPtr)ptr, len, seed));
                Assert.Equal((long)hc, SpookyHash.Hash64((UIntPtr)ptr, len, (long)seed));
                Assert.Equal(hc, SpookyHash.Hash64((IntPtr)ptr, len, seed));
                Assert.Equal((long)hc, SpookyHash.Hash64((IntPtr)ptr, len, (long)seed));
            }

            Assert.Equal(0UL, SpookyHash.Hash64(UIntPtr.Zero, 50, seed));
            Assert.Equal(0L, SpookyHash.Hash64(UIntPtr.Zero, 50, (long)seed));
            Assert.Equal(0UL, SpookyHash.Hash64(IntPtr.Zero, 50, seed));
            Assert.Equal(0L, SpookyHash.Hash64(IntPtr.Zero, 50, (long)seed));
        }
Exemple #3
0
 public unsafe void RehashLong()
 {
     foreach (long seed in RandomLongs(RandomCycleCount))
     {
         foreach (long message in RandomLongs(RandomCycleCount))
         {
             long  copy = message;
             long *p    = ©
             unchecked
             {
                 Assert.Equal((long)SpookyHash.Hash64(p, 8, (ulong)seed), message.Rehash(seed));
             }
         }
     }
     foreach (long message in RandomLongs(RandomCycleCount))
     {
         long  copy = message;
         long *p    = ©
         unchecked
         {
             Assert.Equal((long)SpookyHash.Hash64(p, 8, 0xDEADBEEFDEADBEEF), message.Rehash());
         }
     }
 }