Пример #1
0
        public void CDRepairDecodeNegativeOffsetErrorsTest()
        {
            var  generator2 = new TestImageGenerator("0 999 9801", seed, 32 * 588 - offset, errors);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;

            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(), encode.CRC, out actualOffset, out hasErrors), "couldn't find offset");
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(-offset, actualOffset, "wrong offset");
            var fix = decode.VerifyParity(encode.AR.GetSyndrome(), encode.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            generator2.Write(fix);
            Assert.AreEqual <uint>(encode.CRC, fix.CRC);

            if (AccurateRipVerify.maxNpar > 8)
            {
                fix = decode.VerifyParity(encode.AR.GetSyndrome(8), encode.CRC, actualOffset);
                Assert.IsTrue(fix.HasErrors, "doesn't have errors");
                Assert.IsTrue(fix.CanRecover, "cannot recover");
                generator2.Write(fix);
                Assert.AreEqual <uint>(encode.CRC, fix.CRC);
            }
        }
Пример #2
0
        public void CDRepairDecodeModifiedWithPregapTest()
        {
            var  generator2 = new TestImageGenerator("32 9833", seed, offset, errors);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;

            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(), encode.CRC, out actualOffset, out hasErrors));
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(offset, actualOffset, "wrong offset");
            CDRepairFix fix = decode.VerifyParity(encode.AR.GetSyndrome(), encode.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            generator2.Write(fix);
            Assert.AreEqual <uint>(encode.CRC, fix.CRC);
        }
Пример #3
0
        public void CDRepairDecodePositiveOffsetErrorsTest()
        {
            var  generator2 = new TestImageGenerator("0 9801", seed, 32 * 588 + offset, errors);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;
            var  syn = encode.AR.GetSyndrome();

            Assert.IsTrue(decode.FindOffset(syn, encode.CRC, out actualOffset, out hasErrors));
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(offset, actualOffset, "wrong offset");
            CDRepairFix fix = decode.VerifyParity(syn, encode.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            generator2.Write(fix);
            Assert.AreEqual <uint>(encode.CRC, fix.CRC);
        }