Converted Vignere, added more tests and cleaned stuff up

This commit is contained in:
Matt C 2018-05-09 21:13:09 +01:00
parent 789ec94eff
commit 6bec68021c
7 changed files with 358 additions and 357 deletions

View file

@ -22,6 +22,17 @@ TestRegister.addTests([
}
],
},
{
name: "Affine Encode: invalid a & b (non-integer)",
input: "some keys are shaped as locks. index[me]",
expectedOutput: "The values of a and b can only be integers.",
recipeConfig: [
{
op: "Affine Cipher Encode",
args: [0.1, 0.00001]
}
],
},
{
name: "Affine Encode: no effect",
input: "some keys are shaped as locks. index[me]",
@ -55,6 +66,28 @@ TestRegister.addTests([
}
],
},
{
name: "Affine Decode: invalid a & b (non-integer)",
input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
expectedOutput: "The values of a and b can only be integers.",
recipeConfig: [
{
op: "Affine Cipher Decode",
args: [0.1, 0.00001]
}
],
},
{
name: "Affine Decode: invalid a (coprime)",
input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
expectedOutput: "The value of `a` must be coprime to 26.",
recipeConfig: [
{
op: "Affine Cipher Decode",
args: [8, 23]
}
],
},
{
name: "Affine Decode: no effect",
input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
@ -121,6 +154,17 @@ TestRegister.addTests([
}
],
},
{
name: "Bifid Cipher Encode: invalid key (non-alphabetic)",
input: "We recreate conditions similar to the Van-Allen radiation belt in our secure facilities.",
expectedOutput: "The key must consist only of letters in the English alphabet",
recipeConfig: [
{
"op": "Bifid Cipher Encode",
"args": ["abc123"]
}
],
},
{
name: "Bifid Cipher Encode: normal",
input: "We recreate conditions similar to the Van-Allen radiation belt in our secure facilities.",
@ -154,6 +198,17 @@ TestRegister.addTests([
}
],
},
{
name: "Bifid Cipher Decode: invalid key (non-alphabetic)",
input: "Vq daqcliho rmltofvlnc qbdhlcr nt qdq Fbm-Rdkkm vuoottnoi aitp al axf tdtmvt owppkaodtx.",
expectedOutput: "The key must consist only of letters in the English alphabet",
recipeConfig: [
{
"op": "Bifid Cipher Decode",
"args": ["abc123"]
}
],
},
{
name: "Bifid Cipher Decode: normal",
input: "Wc snpsigdd cpfrrcxnfi hikdnnp dm crc Fcb-Pdeug vueageacc vtyl sa zxm crebzp lyoeuaiwpv.",
@ -165,4 +220,92 @@ TestRegister.addTests([
}
],
},
{
name: "Vigenère Encode: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Vigenère Encode",
"args": ["nothing"]
}
],
},
{
name: "Vigenère Encode: no key",
input: "LUGGAGEBASEMENTVARENNESALLIESCANBECLOTHEDASENEMIESENEMIESCANBECLOTHEDASALLIESALWAYSUSEID",
expectedOutput: "No key entered",
recipeConfig: [
{
"op": "Vigenère Encode",
"args": [""]
}
],
},
{
name: "Vigenère Encode: invalid key",
input: "LUGGAGEBASEMENTVARENNESALLIESCANBECLOTHEDASENEMIESENEMIESCANBECLOTHEDASALLIESALWAYSUSEID",
expectedOutput: "The key must consist only of letters",
recipeConfig: [
{
"op": "Vigenère Encode",
"args": ["abc123"]
}
],
},
{
name: "Vigenère Encode: normal",
input: "LUGGAGEBASEMENTVARENNESALLIESCANBECLOTHEDASENEMIESENEMIESCANBECLOTHEDASALLIESALWAYSUSEID",
expectedOutput: "PXCGRJIEWSVPIQPVRUIQJEJDPOEEJFEQXETOSWDEUDWHJEDLIVANVPMHOCRQFHYLFWLHZAJDPOEEJDPZWYJXWHED",
recipeConfig: [
{
"op": "Vigenère Encode",
"args": ["Edward"]
}
],
},
{
name: "Vigenère Decode: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Vigenère Decode",
"args": ["nothing"]
}
],
},
{
name: "Vigenère Decode: no key",
input: "PXCGRJIEWSVPIQPVRUIQJEJDPOEEJFEQXETOSWDEUDWHJEDLIVANVPMHOCRQFHYLFWLHZAJDPOEEJDPZWYJXWHED",
expectedOutput: "No key entered",
recipeConfig: [
{
"op": "Vigenère Decode",
"args": [""]
}
],
},
{
name: "Vigenère Decode: invalid key",
input: "PXCGRJIEWSVPIQPVRUIQJEJDPOEEJFEQXETOSWDEUDWHJEDLIVANVPMHOCRQFHYLFWLHZAJDPOEEJDPZWYJXWHED",
expectedOutput: "The key must consist only of letters",
recipeConfig: [
{
"op": "Vigenère Decode",
"args": ["abc123"]
}
],
},
{
name: "Vigenère Decode: normal",
input: "PXCGRJIEWSVPIQPVRUIQJEJDPOEEJFEQXETOSWDEUDWHJEDLIVANVPMHOCRQFHYLFWLHZAJDPOEEJDPZWYJXWHED",
expectedOutput: "LUGGAGEBASEMENTVARENNESALLIESCANBECLOTHEDASENEMIESENEMIESCANBECLOTHEDASALLIESALWAYSUSEID",
recipeConfig: [
{
"op": "Vigenère Decode",
"args": ["Edward"]
}
],
},
]);