public void TestVerifyEcc(string codeword, int expectedDataErrPos, int expectedEccErrPos) { if (codeword == null) { throw new ArgumentNullException(nameof(codeword)); } var checksum = int.Parse(codeword.Substring(codeword.Length - 8, 8), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture); var data = HamEcc.StringToByteArray(codeword.Substring(0, codeword.Length - 8)); var result = HamEcc.Verify(data, checksum); Assert.AreEqual((expectedDataErrPos, expectedEccErrPos), result); }
public void TestGenerateChecksum(string data, string expectedEcc) { var result = HamEcc.GenerateChecksum(HamEcc.StringToByteArray(data)); Assert.AreEqual(expectedEcc, result.ToString("X8", CultureInfo.InvariantCulture)); }