Ejemplo n.º 1
0
        public void SimulateDoubleBitErrorTest()
        {
            for (int i = 0; i < 100; i++)
            {
                int            test = rand.Next(Int32.MaxValue);
                HammingInteger hi   = HammingInteger.EncodeInt(test);

                // Simulate double bit error
                hi.SimulateDoubleBitError();

                // builds and checks report
                HammingReport hr = hi.BuildReport();
                Assert.IsTrue(hr.Status == ErrorTypesEnum.MultiBitError);
                Assert.IsTrue(hr.Syndrome > 0);
                Assert.IsFalse(hr.Corrected);

                // Cannot check return value since its uncorrectable
            }
        }
Ejemplo n.º 2
0
        public void SimulateNoErrorsTest()
        {
            for (int i = 0; i < 100; i++)
            {
                int            test = rand.Next(Int32.MaxValue);
                HammingInteger hi   = HammingInteger.EncodeInt(test);

                // Simulate no error by doing nothing

                // builds and checks report
                HammingReport hr = hi.BuildReport();
                Assert.IsTrue(hr.Status == ErrorTypesEnum.NoError);
                Assert.IsTrue(hr.Syndrome == 0);

                // check return value
                int?retVal = hi.RetrieveValue() as int?;
                Assert.IsNotNull(retVal);
                Assert.AreEqual(test, retVal);
            }
        }
Ejemplo n.º 3
0
        public void SimulateSingleDataBitErrorTest()
        {
            for (int i = 0; i < 100; i++)
            {
                int            test = rand.Next(Int32.MaxValue);
                HammingInteger hi   = HammingInteger.EncodeInt(test);

                // Simulate single data bit error
                hi.SimulateSingleDataBitError();

                // builds and checks report
                HammingReport hr = hi.BuildReport();
                Assert.IsTrue(hr.Status == ErrorTypesEnum.DataBitError);
                Assert.IsTrue(hr.Syndrome > 0);
                Assert.IsTrue(hr.Corrected);

                // check return value
                int?retVal = hi.RetrieveValue() as int?;
                Assert.IsNotNull(retVal);
                Assert.AreEqual(test, retVal);
            }
        }