From 92fb9cded0ef7aa5a94c2e13f13ec215c4996b4f Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 22 Apr 2024 16:28:11 +0100 Subject: [PATCH] chore(developer): correct ERROR_ExtendedStringTooLong test following fix #11137 --- .../invalid-keyboards/error_extended_string_too_long.kmn | 3 +-- .../test/fixtures/invalid-keyboards/error_outs_too_long.kmn | 2 +- developer/src/kmc-kmn/test/test-messages.ts | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn index fcae6a5d758..18974124aa2 100644 --- a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn +++ b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn @@ -8,8 +8,7 @@ group(main) using keys c c maximum store length is 4096 UTF-16 code units, including U+0000 terminator c #define GLOBAL_BUFSIZE 4096 // compfile.h -c so we need 0x101B - 0x0020 + 1 = 0x0FFD --> 4092 words, + 4 = 4096 = too long -c See #11136 for calculation adjustment TODO +c so we need 0x101B - 0x0020 + 1 = 0x0FFC --> 4092 words, + 4 = 4096 = too long store(x) U+0020 .. U+101B diff --git a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn index 76d68b97e85..cbd22204152 100644 --- a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn +++ b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn @@ -9,7 +9,7 @@ c maximum store length is 4096 UTF-16 code units, including U+0000 terminator c #define GLOBAL_BUFSIZE 4096 // compfile.h c so we need 0x101D - 0x0020 + 1 = 0x0FFE --> 4094 words c + 1, for 'a' in the rule below = 4095, which triggers the buffer boundary check. -c Noting that this is conservative and losing 2 possible chars, but not fixing +c Noting that this is conservative and losing 1 possible char, but not fixing c in compiler.cpp at this time. store(x) U+0020 .. U+101D diff --git a/developer/src/kmc-kmn/test/test-messages.ts b/developer/src/kmc-kmn/test/test-messages.ts index 9ffe617e70d..29e9222989e 100644 --- a/developer/src/kmc-kmn/test/test-messages.ts +++ b/developer/src/kmc-kmn/test/test-messages.ts @@ -103,9 +103,9 @@ describe('KmnCompilerMessages', function () { // ERROR_ExtendedStringTooLong - it('should generate ERROR_ExtendedStringTooLong if an extended string is too long (more than GLOBAL_BUFSIZE elements)', async function() { + it('should generate ERROR_ExtendedStringTooLong if an extended string is too long and would overflow the buffer', async function() { await testForMessage(this, ['invalid-keyboards', 'error_extended_string_too_long.kmn'], KmnCompilerMessages.ERROR_ExtendedStringTooLong); - // callbacks.printMessages(); + assert.equal(callbacks.messages[0].message, "Extended string is too long character offset: 9"); }); // ERROR_VirtualKeyExpansionTooLong