Converted substitute operation, added tests & moved to OperationError

This commit is contained in:
Matt C 2018-05-11 16:32:19 +01:00
parent 350d10d98b
commit 2d6a56343b
8 changed files with 125 additions and 12 deletions

View file

@ -3,7 +3,7 @@
*
* @author Matt C [matt@artemisbot.uk]
* @author n1474335 [n1474335@gmail.com]
*
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
@ -308,4 +308,48 @@ TestRegister.addTests([
}
],
},
{
name: "Substitute: no pt/ct",
input: "flee at once. we are discovered!",
expectedOutput: "flee at once. we are discovered!",
recipeConfig: [
{
"op": "Substitute",
"args": ["", ""]
}
],
},
{
name: "Substitute: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Substitute",
"args": ["abcdefghijklmnopqrstuvwxyz", "zebrascdfghijklmnopqtuvwxy"]
}
],
},
{
name: "Substitute: uneven pt/ct",
input: "flee at once. we are discovered!",
expectedOutput: "Warning: Plaintext and Ciphertext lengths differ\n\nsiaa zq lkba. va zoa rfpbluaoar!",
recipeConfig: [
{
"op": "Substitute",
"args": ["abcdefghijklmnopqrstuvwxyz", "zebrascdfghijklmnopqtuvwx"]
}
],
},
{
name: "Substitute: normal",
input: "flee at once. we are discovered!",
expectedOutput: "siaa zq lkba. va zoa rfpbluaoar!",
recipeConfig: [
{
"op": "Substitute",
"args": ["abcdefghijklmnopqrstuvwxyz", "zebrascdfghijklmnopqtuvwxy"]
}
],
},
]);