fix: validate To BCD scheme option

This commit is contained in:
Deepak kudi 2026-06-04 15:19:03 +05:30
parent 72ca1aeec7
commit 44b7d045cd
2 changed files with 15 additions and 0 deletions

View File

@ -67,6 +67,10 @@ class ToBCD extends Operation {
signed = args[2],
outputFormat = args[3];
if (!encoding) {
throw new OperationError("Invalid BCD encoding scheme");
}
// Split input number up into separate digits
const digits = input.toFixed().split("");

View File

@ -52,6 +52,17 @@ TestRegister.addTests([
}
]
},
{
name: "To BCD: invalid scheme",
input: "43",
expectedOutput: "Invalid BCD encoding scheme",
recipeConfig: [
{
"op": "To BCD",
"args": ["", true, false, "Nibbles"]
}
]
},
{
name: "From BCD: default 0",
input: "0000",