feat(developer):kmc-convert fix problems from merge; add tests

This commit is contained in:
Sabine 2026-07-02 18:23:51 +02:00
parent 04ae3864c3
commit 14b2e8be46

View file

@ -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);
});
});
});
});