Fix Swap endianness data format validation
This commit is contained in:
parent
d735496641
commit
b870a5ba15
@ -71,7 +71,7 @@ class SwapEndianness extends Operation {
|
||||
data = Utils.strToByteArray(input);
|
||||
break;
|
||||
default:
|
||||
data = input;
|
||||
throw new OperationError("Data format must be Hex or Raw");
|
||||
}
|
||||
|
||||
// Split up into words
|
||||
|
||||
@ -174,6 +174,7 @@ import "./tests/StripTCPHeader.mjs";
|
||||
import "./tests/StripUDPHeader.mjs";
|
||||
import "./tests/Subsection.mjs";
|
||||
import "./tests/SwapCase.mjs";
|
||||
import "./tests/SwapEndianness.mjs";
|
||||
import "./tests/SymmetricDifference.mjs";
|
||||
import "./tests/TakeNthBytes.mjs";
|
||||
import "./tests/Template.mjs";
|
||||
|
||||
33
tests/operations/tests/SwapEndianness.mjs
Normal file
33
tests/operations/tests/SwapEndianness.mjs
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Swap endianness tests.
|
||||
*
|
||||
* @author marko1olo
|
||||
* @copyright Crown Copyright 2026
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Swap endianness: Hex data",
|
||||
input: "0123456789abcdef",
|
||||
expectedOutput: "67 45 23 01 ef cd ab 89",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Swap endianness",
|
||||
args: ["Hex", 4, true],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Swap endianness: empty data format",
|
||||
input: "hello",
|
||||
expectedOutput: "Data format must be Hex or Raw",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Swap endianness",
|
||||
args: ["", 2, true],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user