Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C++

Error Detection Based on Check Digit Schemes

Rate me:
Please Sign up or sign in to vote.
4.72/5 (27 votes)
27 Nov 2007CPOL12 min read 90.8K   2.9K   50  
A Survey of Popular Check Digit Schemes
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test Page for CheckISO7064Mod11_2.js</title>
<script type="text/javascript" src="../CheckISO7064Mod11_2.js"></script>
<script type="text/javascript" src="coretest.js"></script>
<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
<script type="text/javascript" src="jsunitrunner.js"></script>
</head>
<body>
<h1>CheckISO7064Mod11_2 Test</h1>
<script language="javascript" type="text/javascript">

function getCheckInstance() {
   return CheckISO7064Mod11_2;
}

function badTransposition(a, b) {
   return (b == 'X');
}

function testExample() {
   var cd = getCheckInstance();
// example on page 5
assertEquals(0, cd.computeCheck("0794"));
assertEquals("07940", cd.encode("0794"));
assertTrue(cd.verify("07940"));
// example on page 6
assertEquals(10, cd.computeCheck("079"));
assertEquals("079X", cd.encode("079"));
assertTrue(cd.verify("079X"));

}
var testcases = [testCheck, testSingleError, 
                 testAdjacentTraspositions, testExample];
TestRunner.RunTests(testcases);

</script>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems / Hardware Administrator
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions