Validate Wrap line width (#2606)
Co-authored-by: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> Co-authored-by: C85297 <95289555+C85297@users.noreply.github.com>
This commit is contained in:
parent
961bbab682
commit
179eb9a379
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
const MAX_LINE_WIDTH = 65536;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap operation
|
* Wrap operation
|
||||||
*/
|
*/
|
||||||
@ -27,6 +29,9 @@ class Wrap extends Operation {
|
|||||||
"name": "Line Width",
|
"name": "Line Width",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 64,
|
"value": 64,
|
||||||
|
"min": 1,
|
||||||
|
"max": MAX_LINE_WIDTH,
|
||||||
|
"integer": true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,5 +40,49 @@ TestRegister.addTests([
|
|||||||
"args": [10]
|
"args": [10]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects zero line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be greater than or equal to 1.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [0]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects negative line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be greater than or equal to 1.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [-1]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects non-integer line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be an integer.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [1.1]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects excessive line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be less than or equal to 65536.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [65537]
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user