1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-18 04:04:03 +03:00

test_unicode_norm: fix display of failing tests.

There was a bytes / array elements confusion in the code that prints
out the input and output Unicode strings when a test fails. It was
using a loop with index variable 'pos', which was used as an array
index, but incremented by sizeof(a character) each time, leading to
only every fourth character actually being printed.

I assume this is leftover confusion from when I hadn't quite decided
whether to abuse the char-based strbuf for these Unicode character
buffers, or make a specialist type.

Discovered when I reached for this test program just now in order to
manually decompose a Unicode string. It doesn't have a convenient CLI
for that, but it was a thing I already knew where to find!
This commit is contained in:
Simon Tatham 2025-04-04 23:00:35 +01:00
parent 7a100534d3
commit 6332497afb

View File

@ -341,13 +341,13 @@ static void subtest(const char *filename, int lineno, const char *subdesc,
pass++;
} else {
printf("%s:%d: failed %s: NF%c([", filename, lineno, subdesc, nftype);
for (size_t pos = 0; pos < input->len; pos += sizeof(uchar))
for (size_t pos = 0; pos < input->len; pos++)
printf("%s%04X", pos ? " " : "", (unsigned)input->buf[pos]);
printf("]) -> [");
for (size_t pos = 0; pos < nf->len; pos += sizeof(uchar))
for (size_t pos = 0; pos < nf->len; pos++)
printf("%s%04X", pos ? " " : "", (unsigned)nf->buf[pos]);
printf("] != [");
for (size_t pos = 0; pos < expected->len; pos += sizeof(uchar))
for (size_t pos = 0; pos < expected->len; pos++)
printf("%s%04X", pos ? " " : "", (unsigned)expected->buf[pos]);
printf("]\n");
fail++;