CyberChef/tests/operations/tests/LuhnChecksum.mjs

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-02-26 10:55:15 +00:00
/**
* From Decimal tests
*
* @author n1073645 [n1073645@gmail.com]
* @copyright Crown Copyright 2020
* @licence Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Luhn Checksum on standard data",
input: "35641709012469",
2020-03-12 14:41:46 +00:00
expectedOutput: "Checksum: 7\nCheckdigit: 0\nLuhn Validated String: 356417090124690",
2020-03-09 09:37:34 +00:00
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
},
{
name: "Luhn Checksum on standard data 2",
input: "896101950123440000",
2020-03-12 14:41:46 +00:00
expectedOutput: "Checksum: 5\nCheckdigit: 1\nLuhn Validated String: 8961019501234400001",
2020-03-09 09:37:34 +00:00
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
},
{
name: "Luhn Checksum on standard data 3",
input: "35726908971331",
2020-03-12 14:41:46 +00:00
expectedOutput: "Checksum: 6\nCheckdigit: 7\nLuhn Validated String: 357269089713317",
2020-02-26 10:55:15 +00:00
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
},
{
name: "Luhn Checksum on invalid data",
input: "35641709b012469",
expectedOutput: "Character: b is not a digit.",
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
},
{
name: "Luhn Checksum on empty data",
input: "",
2020-03-12 14:41:46 +00:00
expectedOutput: "",
2020-02-26 10:55:15 +00:00
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
}
]);