mirror of
https://github.com/gchq/CyberChef
synced 2025-01-12 04:28:53 +00:00
Add tests
Added tests for 'Drop nth bytes' operation.
This commit is contained in:
parent
30349dbcb9
commit
b125f82784
2 changed files with 124 additions and 0 deletions
|
@ -91,6 +91,7 @@ import "./tests/Protobuf.mjs";
|
||||||
import "./tests/ParseSSHHostKey.mjs";
|
import "./tests/ParseSSHHostKey.mjs";
|
||||||
import "./tests/DefangIP.mjs";
|
import "./tests/DefangIP.mjs";
|
||||||
import "./tests/ParseUDP.mjs";
|
import "./tests/ParseUDP.mjs";
|
||||||
|
import "./tests/DropNthBytes.mjs";
|
||||||
|
|
||||||
// Cannot test operations that use the File type yet
|
// Cannot test operations that use the File type yet
|
||||||
// import "./tests/SplitColourChannels.mjs";
|
// import "./tests/SplitColourChannels.mjs";
|
||||||
|
|
123
tests/operations/tests/DropNthBytes.mjs
Normal file
123
tests/operations/tests/DropNthBytes.mjs
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
/**
|
||||||
|
* @author Oshawk [oshawk@protonmail.com]
|
||||||
|
* @copyright Crown Copyright 2019
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop nth bytes tests
|
||||||
|
*/
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Nothing",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 0, false],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Nothing (apply to each line)",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 0, true],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Basic single line",
|
||||||
|
input: "0123456789",
|
||||||
|
expectedOutput: "1235679",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 0, false],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Basic single line (apply to each line)",
|
||||||
|
input: "0123456789",
|
||||||
|
expectedOutput: "1235679",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 0, true],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Complex single line",
|
||||||
|
input: "0123456789",
|
||||||
|
expectedOutput: "01234678",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 5, false],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Complex single line (apply to each line)",
|
||||||
|
input: "0123456789",
|
||||||
|
expectedOutput: "01234678",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 5, true],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Basic multi line",
|
||||||
|
input: "01234\n56789",
|
||||||
|
expectedOutput: "123\n5689",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 0, false],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Basic multi line (apply to each line)",
|
||||||
|
input: "01234\n56789",
|
||||||
|
expectedOutput: "123\n678",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 0, true],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Complex multi line",
|
||||||
|
input: "01234\n56789",
|
||||||
|
expectedOutput: "012345679",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 5, false],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Drop nth bytes: Complex multi line (apply to each line)",
|
||||||
|
input: "012345\n6789ab",
|
||||||
|
expectedOutput: "01234\n6789a",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Drop nth bytes",
|
||||||
|
args: [4, 5, true],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]);
|
Loading…
Reference in a new issue