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:
Kirill 2026-07-03 13:06:55 +03:00 committed by GitHub
parent 961bbab682
commit 179eb9a379
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 0 deletions

View File

@ -6,6 +6,8 @@
import Operation from "../Operation.mjs";
const MAX_LINE_WIDTH = 65536;
/**
* Wrap operation
*/
@ -27,6 +29,9 @@ class Wrap extends Operation {
"name": "Line Width",
"type": "number",
"value": 64,
"min": 1,
"max": MAX_LINE_WIDTH,
"integer": true,
},
];
}

View File

@ -40,5 +40,49 @@ TestRegister.addTests([
"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]
},
],
}
]);