From af73325840f7cfda9b55eb5ee605f6c40f5a0d12 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 27 Aug 2025 08:28:11 +0000 Subject: [PATCH] Added tests --- tests/operations/index.mjs | 1 + tests/operations/tests/Ngram.mjs | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/operations/tests/Ngram.mjs diff --git a/tests/operations/index.mjs b/tests/operations/index.mjs index f147e9e7..7487480f 100644 --- a/tests/operations/index.mjs +++ b/tests/operations/index.mjs @@ -114,6 +114,7 @@ import "./tests/MS.mjs"; import "./tests/MultipleBombe.mjs"; import "./tests/MurmurHash3.mjs"; import "./tests/NetBIOS.mjs"; +import "./tests/Ngram.mjs"; import "./tests/NormaliseUnicode.mjs"; import "./tests/NTLM.mjs"; import "./tests/OTP.mjs"; diff --git a/tests/operations/tests/Ngram.mjs b/tests/operations/tests/Ngram.mjs new file mode 100644 index 00000000..97af9d12 --- /dev/null +++ b/tests/operations/tests/Ngram.mjs @@ -0,0 +1,34 @@ +/** + * Ngram tests. + * + * @author jg42526 + * + * @copyright Crown Copyright 2017 + * @license Apache-2.0 + */ +import TestRegister from "../../lib/TestRegister.mjs"; + +TestRegister.addTests([ + { + name: "Ngram 3", + input: "hello", + expectedOutput: "hel,ell,llo", + recipeConfig: [ + { + op: "N-gram", + args: ["3", ","], + }, + ], + }, + { + name: "Ngram longer than input", + input: "hello", + expectedOutput: "", + recipeConfig: [ + { + op: "N-gram", + args: ["6", ","], + }, + ], + }, +]);