Exemplo n.º 1
0
        public void TestAddByteRange()
        {
            Crc64 all = new Crc64(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
            Crc64 crc = new Crc64();

            Assert.AreEqual(0, crc.Value);
            crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
            Assert.AreEqual(all.Value, crc.Value);
        }
Exemplo n.º 2
0
        public void TestHashValue()
        {
            Crc64 crc = new Crc64();

            Assert.AreEqual(0, crc.Value);
            Assert.AreEqual(0, crc.GetHashCode());

            crc.Add(0x1b);

            Assert.AreNotEqual(0, crc.Value);
            Assert.AreEqual((int)crc.Value ^ (int)(crc.Value >> 32), crc.GetHashCode());
        }
Exemplo n.º 3
0
        private static void AssertCrc64(byte[] input, ulong expectedu)
        {
            long expected = unchecked((long) expectedu);
            Crc64 crc = new Crc64(input);
            Assert.AreEqual(expected, crc.Value);

            crc = new Crc64(0);
            crc.Add(input);
            Assert.AreEqual(expected, crc.Value);

            crc = new Crc64();
            crc.Add(input, 0, input.Length);
            Assert.AreEqual(expected, crc.Value);

            crc = new Crc64();
            foreach (byte b in input)
                crc.Add(b);
            Assert.AreEqual(expected, crc.Value);
        }
Exemplo n.º 4
0
        private static void AssertCrc64(byte[] input, ulong expectedu)
        {
            long  expected = unchecked ((long)expectedu);
            Crc64 crc      = new Crc64(input);

            Assert.AreEqual(expected, crc.Value);

            crc = new Crc64(0);
            crc.Add(input);
            Assert.AreEqual(expected, crc.Value);

            crc = new Crc64();
            crc.Add(input, 0, input.Length);
            Assert.AreEqual(expected, crc.Value);

            crc = new Crc64();
            foreach (byte b in input)
            {
                crc.Add(b);
            }
            Assert.AreEqual(expected, crc.Value);
        }
Exemplo n.º 5
0
 public void TestAddByteRange()
 {
     Crc64 all = new Crc64(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
     Crc64 crc = new Crc64();
     Assert.AreEqual(0, crc.Value);
     crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
     Assert.AreEqual(all.Value, crc.Value);
 }
Exemplo n.º 6
0
        public void TestHashValue()
        {
            Crc64 crc = new Crc64();
            Assert.AreEqual(0, crc.Value);
            Assert.AreEqual(0, crc.GetHashCode());

            crc.Add(0x1b);

            Assert.AreNotEqual(0, crc.Value);
            Assert.AreEqual((int)crc.Value ^ (int)(crc.Value >> 32), crc.GetHashCode());
        }