mirror of
https://github.com/gchq/CyberChef.git
synced 2026-03-21 22:34:23 -07:00
Move median tests into operations suite
This commit is contained in:
parent
b16f9ec134
commit
4865806baa
4 changed files with 34 additions and 18 deletions
|
|
@ -22,7 +22,6 @@ import "./tests/File.mjs";
|
|||
import "./tests/Dish.mjs";
|
||||
import "./tests/NodeDish.mjs";
|
||||
import "./tests/Utils.mjs";
|
||||
import "./tests/Arithmetic.mjs";
|
||||
import "./tests/Categories.mjs";
|
||||
import "./tests/lib/BigIntUtils.mjs";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
import assert from "assert";
|
||||
import BigNumber from "bignumber.js";
|
||||
import it from "../assertionHandler.mjs";
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
import { median } from "../../../src/core/lib/Arithmetic.mjs";
|
||||
|
||||
TestRegister.addApiTests([
|
||||
it("Arithmetic: median sorts odd-length input", () => {
|
||||
const result = median([new BigNumber(10), new BigNumber(1), new BigNumber(2)]);
|
||||
assert.strictEqual(result.toString(), "2");
|
||||
}),
|
||||
|
||||
it("Arithmetic: median keeps even-length behavior", () => {
|
||||
const result = median([new BigNumber(10), new BigNumber(1), new BigNumber(2), new BigNumber(5)]);
|
||||
assert.strictEqual(result.toString(), "3.5");
|
||||
}),
|
||||
]);
|
||||
|
|
@ -109,6 +109,7 @@ import "./tests/LuhnChecksum.mjs";
|
|||
import "./tests/LZNT1Decompress.mjs";
|
||||
import "./tests/LZString.mjs";
|
||||
import "./tests/Magic.mjs";
|
||||
import "./tests/Median.mjs";
|
||||
import "./tests/Media.mjs";
|
||||
import "./tests/MIMEDecoding.mjs";
|
||||
import "./tests/Modhex.mjs";
|
||||
|
|
|
|||
33
tests/operations/tests/Median.mjs
Normal file
33
tests/operations/tests/Median.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Median operation tests.
|
||||
*
|
||||
* @author copilot-swe-agent[bot]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Median: sorts odd-length input",
|
||||
input: "10 1 2",
|
||||
expectedOutput: "2",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Median",
|
||||
args: ["Space"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Median: keeps even-length behavior",
|
||||
input: "10 1 2 5",
|
||||
expectedOutput: "3.5",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Median",
|
||||
args: ["Space"],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue