mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Add more tests for flow control ops
This commit is contained in:
parent
c39622ed1e
commit
02f855ff09
1 changed files with 133 additions and 0 deletions
|
@ -66,6 +66,62 @@ TestRegister.addTests([
|
||||||
{"op":"To Base64", "args":["A-Za-z0-9+/="]}
|
{"op":"To Base64", "args":["A-Za-z0-9+/="]}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Jump: skips 0",
|
||||||
|
input: [
|
||||||
|
"should be changed",
|
||||||
|
].join("\n"),
|
||||||
|
expectedOutput: [
|
||||||
|
"should be changed was changed",
|
||||||
|
].join("\n"),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Jump",
|
||||||
|
args: [0, 10],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "Find / Replace",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
"option": "Regex",
|
||||||
|
"string": "should be changed"
|
||||||
|
},
|
||||||
|
"should be changed was changed",
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Jump: skips 1",
|
||||||
|
input: [
|
||||||
|
"shouldnt be changed",
|
||||||
|
].join("\n"),
|
||||||
|
expectedOutput: [
|
||||||
|
"shouldnt be changed",
|
||||||
|
].join("\n"),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Jump",
|
||||||
|
args: [1, 10],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "Find / Replace",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
"option": "Regex",
|
||||||
|
"string": "shouldnt be changed"
|
||||||
|
},
|
||||||
|
"shouldnt be changed was changed",
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Conditional Jump: Skips 0",
|
name: "Conditional Jump: Skips 0",
|
||||||
input: [
|
input: [
|
||||||
|
@ -111,4 +167,81 @@ TestRegister.addTests([
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Conditional Jump: Skips 1",
|
||||||
|
input: [
|
||||||
|
"match",
|
||||||
|
"should not be changed",
|
||||||
|
"should be changed",
|
||||||
|
].join("\n"),
|
||||||
|
expectedOutput: [
|
||||||
|
"match",
|
||||||
|
"should not be changed",
|
||||||
|
"should be changed was changed"
|
||||||
|
].join("\n"),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Conditional Jump",
|
||||||
|
args: ["match", 1, 10],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "Find / Replace",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
"option": "Regex",
|
||||||
|
"string": "should not be changed"
|
||||||
|
},
|
||||||
|
"should not be changed was changed",
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "Find / Replace",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
"option": "Regex",
|
||||||
|
"string": "should be changed"
|
||||||
|
},
|
||||||
|
"should be changed was changed",
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Conditional Jump: Skips negatively",
|
||||||
|
input: [
|
||||||
|
"match",
|
||||||
|
].join("\n"),
|
||||||
|
expectedOutput: [
|
||||||
|
"replaced",
|
||||||
|
].join("\n"),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Jump",
|
||||||
|
args: [1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "Find / Replace",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
"option": "Regex",
|
||||||
|
"string": "match"
|
||||||
|
},
|
||||||
|
"replaced",
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "Conditional Jump",
|
||||||
|
args: ["match", -2, 10],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue