From 11cdb2c25c0a1fb7d9e43ea9349719940b635e36 Mon Sep 17 00:00:00 2001 From: marko1olo Date: Sat, 6 Jun 2026 03:53:51 +0400 Subject: [PATCH] Fix From BCD scheme validation --- src/core/operations/FromBCD.mjs | 4 ++++ tests/operations/tests/BCD.mjs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/core/operations/FromBCD.mjs b/src/core/operations/FromBCD.mjs index 8fa990a4..2a2fc8eb 100644 --- a/src/core/operations/FromBCD.mjs +++ b/src/core/operations/FromBCD.mjs @@ -70,6 +70,10 @@ class FromBCD extends Operation { inputFormat = args[3], nibbles = []; + if (!encoding) { + throw new OperationError("Invalid BCD encoding scheme"); + } + let output = "", byteArray; diff --git a/tests/operations/tests/BCD.mjs b/tests/operations/tests/BCD.mjs index c6715e56..8b573bcd 100644 --- a/tests/operations/tests/BCD.mjs +++ b/tests/operations/tests/BCD.mjs @@ -85,6 +85,17 @@ TestRegister.addTests([ } ] }, + { + name: "From BCD: invalid encoding scheme", + input: "1000", + expectedOutput: "Invalid BCD encoding scheme", + recipeConfig: [ + { + "op": "From BCD", + "args": ["", true, false, "Nibbles"] + } + ] + }, { name: "BCD: raw 4 2 2 1, packed, signed", input: "1234567890",