Add comprehensive tests for Text-Integer Conversion operation
This commit is contained in:
parent
f1cb2f20d8
commit
300c534775
@ -162,6 +162,7 @@ import "./tests/SymmetricDifference.mjs";
|
||||
import "./tests/TakeNthBytes.mjs";
|
||||
import "./tests/Template.mjs";
|
||||
import "./tests/TextEncodingBruteForce.mjs";
|
||||
import "./tests/TextIntegerConverter.mjs";
|
||||
import "./tests/ToFromInsensitiveRegex.mjs";
|
||||
import "./tests/TranslateDateTimeFormat.mjs";
|
||||
import "./tests/Typex.mjs";
|
||||
|
||||
163
tests/operations/tests/TextIntegerConverter.mjs
Normal file
163
tests/operations/tests/TextIntegerConverter.mjs
Normal file
@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Text-Integer Conversion tests.
|
||||
*
|
||||
* @author p-leriche [philip.leriche@cantab.net]
|
||||
*
|
||||
* @copyright Crown Copyright 2025
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Text-Integer Conversion quoted string to decimal",
|
||||
input: "\"ABC\"",
|
||||
expectedOutput: "4276803",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion quoted string to hexadecimal",
|
||||
input: "\"ABC\"",
|
||||
expectedOutput: "0x414243",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Hexadecimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion single quoted string to decimal",
|
||||
input: "'Hello'",
|
||||
expectedOutput: "310939249775",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion decimal to string",
|
||||
input: "4276803",
|
||||
expectedOutput: "ABC",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["String"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion hexadecimal to string",
|
||||
input: "0x48656C6C6F",
|
||||
expectedOutput: "Hello",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["String"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion round-trip string.decimal.string",
|
||||
input: "\"Test\"",
|
||||
expectedOutput: "Test",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["String"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion round-trip string.hex.string",
|
||||
input: "\"CyberChef\"",
|
||||
expectedOutput: "CyberChef",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Hexadecimal"],
|
||||
},
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["String"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion unquoted text to decimal",
|
||||
input: "Hi",
|
||||
expectedOutput: "18537",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion single character",
|
||||
input: "\"A\"",
|
||||
expectedOutput: "65",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion hex to decimal conversion",
|
||||
input: "0xFF",
|
||||
expectedOutput: "255",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion decimal to hex conversion",
|
||||
input: "255",
|
||||
expectedOutput: "0xff",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Hexadecimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion large number to string",
|
||||
input: "113091951015816448506195587157728348242683688608116",
|
||||
expectedOutput: "Mary had a little cat",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["String"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Text-Integer Conversion whitespace handling (quoted)",
|
||||
input: "\" test \"",
|
||||
expectedOutput: "2314978187545944096",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Text-Integer Conversion",
|
||||
args: ["Decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user