Validate View Bit Plane colour input
This commit is contained in:
parent
a0a369a7ef
commit
a7acad4211
@ -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",
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user