Converted Affine/Atbash operations to mjs & added tests

This commit is contained in:
Matt C 2018-05-09 20:18:33 +01:00
parent 6987e6b1b9
commit f87666f659
6 changed files with 394 additions and 6 deletions

View file

@ -30,8 +30,9 @@ import "./tests/operations/Base64";
// import "./tests/operations/BitwiseOp.js";
// import "./tests/operations/BSON.js";
// import "./tests/operations/ByteRepr.js";
import "./tests/operations/CartesianProduct";
// import "./tests/operations/CharEnc.js";
// import "./tests/operations/Cipher.js";
import "./tests/operations/Ciphers";
// import "./tests/operations/Code.js";
// import "./tests/operations/Compress.js";
// import "./tests/operations/DateTime.js";
@ -44,16 +45,15 @@ import "./tests/operations/Base64";
// import "./tests/operations/PHP.js";
// import "./tests/operations/NetBIOS.js";
// import "./tests/operations/OTP.js";
import "./tests/operations/PowerSet";
// import "./tests/operations/Regex.js";
import "./tests/operations/Rotate.mjs";
import "./tests/operations/Rotate";
// import "./tests/operations/StrUtils.js";
// import "./tests/operations/SeqUtils.js";
import "./tests/operations/SetUnion";
import "./tests/operations/SetIntersection";
import "./tests/operations/SetDifference";
import "./tests/operations/SetIntersection";
import "./tests/operations/SetUnion";
import "./tests/operations/SymmetricDifference";
import "./tests/operations/CartesianProduct";
import "./tests/operations/PowerSet";
let allTestsPassing = true;
const testStatusCounts = {

View file

@ -0,0 +1,102 @@
/**
* Cipher tests.
*
* @author Matt C [matt@artemisbot.uk]
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister";
TestRegister.addTests([
{
name: "Affine Encode: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Affine Cipher Encode",
args: [1, 0]
}
],
},
{
name: "Affine Encode: no effect",
input: "some keys are shaped as locks. index[me]",
expectedOutput: "some keys are shaped as locks. index[me]",
recipeConfig: [
{
op: "Affine Cipher Encode",
args: [1, 0]
}
],
},
{
name: "Affine Encode: normal",
input: "some keys are shaped as locks. index[me]",
expectedOutput: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
recipeConfig: [
{
op: "Affine Cipher Encode",
args: [23, 23]
}
],
},
{
name: "Affine Decode: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Affine Cipher Decode",
args: [1, 0]
}
],
},
{
name: "Affine Decode: no effect",
input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
expectedOutput: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
recipeConfig: [
{
op: "Affine Cipher Decode",
args: [1, 0]
}
],
},
{
name: "Affine Decode: normal",
input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
expectedOutput: "some keys are shaped as locks. index[me]",
recipeConfig: [
{
op: "Affine Cipher Decode",
args: [23, 23]
}
],
},
{
name: "Atbash: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Atbash Cipher",
args: []
}
],
},
{
name: "Atbash: normal",
input: "old slow slim horn",
expectedOutput: "low hold horn slim",
recipeConfig: [
{
op: "Atbash Cipher",
args: []
}
],
},
]);