Typex: add simple tests

This commit is contained in:
s2224834 2019-02-28 17:22:09 +00:00
parent 1f9fd92b01
commit 765aded208
2 changed files with 106 additions and 0 deletions

View File

@ -86,6 +86,7 @@ import "./tests/ConvertCoordinateFormat";
import "./tests/Enigma";
import "./tests/Bombe";
import "./tests/MultipleBombe";
import "./tests/Typex";
// Cannot test operations that use the File type yet
//import "./tests/SplitColourChannels";

View File

@ -0,0 +1,105 @@
/**
* Typex machine tests.
* @author s2224834
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
TestRegister.addTests([
{
// Unlike Enigma we're not verifying against a real machine here, so this is just a test
// to catch inadvertent breakage.
name: "Typex: basic",
input: "hello world, this is a test message.",
expectedOutput: "VIXQQ VHLPN UCVLA QDZNZ EAYAT HWC",
recipeConfig: [
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"None", true
]
}
]
},
{
name: "Typex: keyboard",
input: "hello world, this is a test message.",
expectedOutput: "VIXQQ FDJXT WKLDQ DFQOD CNCSK NULBG JKQDD MVGQ",
recipeConfig: [
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"Encrypt", true
]
}
]
},
{
name: "Typex: self-decrypt",
input: "hello world, this is a test message.",
expectedOutput: "HELLO WORLD, THIS IS A TEST MESSAGE.",
recipeConfig: [
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"Encrypt", true
]
},
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"Decrypt", true
]
}
]
},
]);