コード例 #1
0
        public void Ccitt_ItCalculates()
        {
            byte[] testData = Encoding.ASCII.GetBytes("123456789");

            UInt16 expected = 0x29B1;
            UInt16 given    = CrcCcitt.Calculate(testData);


            Assert.AreEqual(expected, given);
        }
コード例 #2
0
        public void Ccitt_ItChecks()
        {
            byte[] testData = Encoding.ASCII.GetBytes("123456789");
            byte[] crc      = { 0x29, 0xB1 };
            byte[] input    = new byte[testData.Length + crc.Length];

            Buffer.BlockCopy(testData, 0, input, 0, testData.Length);
            Buffer.BlockCopy(crc, 0, input, testData.Length, crc.Length);

            bool given = CrcCcitt.Check(input);

            Assert.IsTrue(given);
        }