From 14b2e8be46ee2d4d79c7d1eeb4b1b99c845ef029 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 2 Jul 2026 18:23:51 +0200 Subject: [PATCH] feat(developer):kmc-convert fix problems from merge; add tests --- .../kmc-convert/test/kmn-file-writer.tests.ts | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/developer/src/kmc-convert/test/kmn-file-writer.tests.ts b/developer/src/kmc-convert/test/kmn-file-writer.tests.ts index 896031f1dc..64f0f3762c 100644 --- a/developer/src/kmc-convert/test/kmn-file-writer.tests.ts +++ b/developer/src/kmc-convert/test/kmn-file-writer.tests.ts @@ -108,7 +108,7 @@ describe('KmnFileWriter', function () { describe('reviewRules messages', function () { const sutW = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions); - [/* + [ [[new Rule("C0", '', '', 0, 0, '', '', 0, 0, 'UNAVAILABLE', 'K_A', new TextEncoder().encode('A'))], [''], [''], @@ -442,5 +442,42 @@ describe('KmnFileWriter', function () { }); }); }); +describe('writeCharacterOrUnicode and return values', function () { + const sutW = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions); + [ + ["A", "A", "Msg "], + ["ሴ", "ሴ", "Msg "], + ["πŸ˜€", "πŸ˜€", "Msg "], + ["ẘ", "ẘ", "Msg "], + ["U+0001", "U+0001", "Msg Use of a control character "], + ["U+0061", "a", "Msg "], + ["", "U+0002", "Msg Use of a control character "], + ["ሴ", 'ሴ', "Msg "], + ["", "U+0003", "Msg Use of a control character "], + ["ሺ", "ሺ", "Msg "], + ["", "U+0006", "Msg Use of a control character "], + ['', '', 'Msg empty output or unsupported numerical html entity: '], + ].forEach(function (values) { + it(('should convert "' + values[0] + '"').padEnd(25, " ") + 'to "' + values[1] + '"', async function () { + const result = sutW.writeCharacterOrUnicode(values[0] as string, "Msg "); + assert.isNotNull(result); + assert.equal(result.character, values[1]); + assert.equal(result.message, values[2]); + }); + }); + }); + describe('writeCharacterOrUnicode and return null for result.message and result.character', function () { + const sutW = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions); + [ + [null, null], + [undefined, null], + + ].forEach(function (values) { + it(('should convert "' + values[0] + '"').padEnd(25, " ") + 'to "' + values[1] + '"', async function () { + const result = sutW.writeCharacterOrUnicode(values[0], ""); + assert.isNull(result); + }); + }); + }); });