Ejemplo n.º 1
0
        public void TestHash32Span()
        {
            var         data     = new byte[] { 1 };
            Span <byte> sp       = data;
            var         expected = Farmhash.Hash32(data, data.Length);

            Assert.Equal(Farmhash.Hash32(sp), expected);
        }
Ejemplo n.º 2
0
        public unsafe void TestHash32(String str, uint expected)
        {
            var bytes = Encoding.ASCII.GetBytes(str);

            Assert.Equal(Farmhash.Hash32(bytes, bytes.Length), expected);
            fixed(byte *ptr = bytes)
            {
                Assert.Equal(Farmhash.Hash32(ptr, bytes.Length), expected);
            }

            var strBytes = Encoding.Unicode.GetBytes(str);

            Assert.Equal(Farmhash.Hash32(strBytes, strBytes.Length), Farmhash.Hash32(str));

#if NETCOREAPP2_1
            Span <byte> sp = bytes;
            Assert.Equal(Farmhash.Hash32(sp), expected);
#endif
        }
Ejemplo n.º 3
0
        public void TestHash32(String str, uint expected)
        {
            var bytes = Encoding.ASCII.GetBytes(str);

            Assert.Equal(Farmhash.Hash32(bytes, bytes.Length), expected);
        }
Ejemplo n.º 4
0
 public uint FarmHash() => Farmhash.Hash32(data, data.Length);