Luhn Checksum Operation Added

This commit is contained in:
n1073645 2020-02-26 10:55:15 +00:00
parent d78730edc0
commit 940b56ba5f
4 changed files with 108 additions and 0 deletions

View file

@ -97,6 +97,7 @@ import "./tests/DefangIP.mjs";
import "./tests/ParseUDP.mjs";
import "./tests/AvroToJSON.mjs";
import "./tests/Lorenz.mjs";
import "./tests/LuhnChecksum.mjs";
// Cannot test operations that use the File type yet

View file

@ -0,0 +1,44 @@
/**
* 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",
expectedOutput: "7",
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: "",
expectedOutput: "0",
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
}
]);