mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 00:36:16 -04:00
Luhn Checksum Operation Added
This commit is contained in:
parent
d78730edc0
commit
940b56ba5f
4 changed files with 108 additions and 0 deletions
|
@ -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
|
||||
|
|
44
tests/operations/tests/LuhnChecksum.mjs
Normal file
44
tests/operations/tests/LuhnChecksum.mjs
Normal 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: []
|
||||
},
|
||||
],
|
||||
}
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue