Validate View Bit Plane colour input

This commit is contained in:
Kairos Ops 2026-06-21 07:22:26 +08:00
parent a0a369a7ef
commit a7acad4211
2 changed files with 21 additions and 0 deletions

View File

@ -59,6 +59,12 @@ class ViewBitPlane extends Operation {
colourIndex = COLOUR_OPTIONS.indexOf(colour),
bitIndex = 7 - bit;
if (colourIndex === -1) {
throw new OperationError(
`Error: Colour argument must be one of ${COLOUR_OPTIONS.join(", ")}`,
);
}
if (bit < 0 || bit > 7) {
throw new OperationError(
"Error: Bit argument must be between 0 and 7",

View File

@ -230,6 +230,21 @@ TestRegister.addTests([
}
]
},
{
name: "View Bit Plane: invalid colour",
input: PNG_HEX,
expectedOutput: "Error: Colour argument must be one of Red, Green, Blue, Alpha",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "View Bit Plane",
args: ["", 7]
},
],
},
{
name: "Randomize Colour Palette",
"input": PNG_HEX,