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 } }
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); } }
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); } }