Ejemplo n.º 1
0
        public void CRC32_sample_value_stream_too_short_buffered()
        {
            var buffer = Enumerable.Range(0, 10000000).Select(i => (byte)i).ToArray();

            using (var stream = new MemoryStream(buffer))
            {
                Assert.Throws <ArgumentException>(() =>
                                                  Checksum.CRC32(stream, 0, buffer.Length + 1).ToString("X8"));
            }
        }
Ejemplo n.º 2
0
        public void CRC32_sample_value_stream()
        {
            var buffer = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };

            using (var stream = new MemoryStream(buffer))
            {
                Assert.Equal("CBF43926",
                             Checksum.CRC32(stream, 0, buffer.Length).ToString("X8"));
            }
        }
Ejemplo n.º 3
0
        public void CRC32_sample_value_stream_buffered()
        {
            var buffer = Enumerable.Range(0, 10000000).Select(i => (byte)i).ToArray();

            using (var stream = new MemoryStream(buffer))
            {
                Assert.Equal("14BFFAE4",
                             Checksum.CRC32(stream, 0, buffer.Length).ToString("X8"));
            }
        }
Ejemplo n.º 4
0
        public void CRC32_sample_value_rospan()
        {
            var buffer = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };

            var crc = Checksum.CRC32(buffer.AsSpan(0, 9));

            // See http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
            // See http://www.lammertbies.nl/comm/info/crc-calculation.html
            Assert.Equal("CBF43926", crc.ToString("X8"));
        }