pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Unicode normalization test broken output
Date: Mon, 9 Dec 2019 12:05:30 +0100
Message-ID: <6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb@2ndquadrant.com> (raw)

I was playing with the Unicode normalization test in 
src/common/unicode/.  I think there is something wrong with how the test 
program reports failures.  For example, if I manually edit the 
norm_test_table.h to make a failure, like

-    { 74, { 0x00A8, 0 }, { 0x0020, 0x0308, 0 } },
+    { 74, { 0x00A8, 0 }, { 0x0020, 0x0309, 0 } },

then the output from the test is

FAILURE (NormalizationTest.txt line 74):
input:	00
expected:	0003
got	0003

which doesn't make sense.

There appear to be several off-by-more-than-one errors in norm_test.c 
print_wchar_str().  Attached is a patch to fix this (and make the output 
a bit prettier).  Result afterwards:

FAILURE (NormalizationTest.txt line 74):
input:    U+00A8
expected: U+0020 U+0309
got:      U+0020 U+0308

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Fix-output-of-Unicode-normalization-test.patch (text/plain, 1.5K) download From b9dce0b6185ce8a05780d64a5a284b3eb7c7e7ea Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter@eisentraut.org> Date: Mon, 9 Dec 2019 12:02:49 +0100 Subject: [PATCH] Fix output of Unicode normalization test Several off-by-more-than-one errors caused the output in case of a test failure to be unintelligible. --- src/common/unicode/norm_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/unicode/norm_test.c b/src/common/unicode/norm_test.c index fee58a184a..b6d34dd22c 100644 --- a/src/common/unicode/norm_test.c +++ b/src/common/unicode/norm_test.c @@ -23,17 +23,17 @@ static char * print_wchar_str(const pg_wchar *s) { #define BUF_DIGITS 50 - static char buf[BUF_DIGITS * 2 + 1]; + static char buf[BUF_DIGITS * 7 + 1]; int i; i = 0; while (*s && i < BUF_DIGITS) { - snprintf(&buf[i * 2], 3, "%04X", *s); + sprintf(&buf[i * 7], "U+%04X ", *s); i++; s++; } - buf[i * 2] = '\0'; + buf[i * 7] = '\0'; return buf; } @@ -67,9 +67,9 @@ main(int argc, char **argv) if (pg_wcscmp(test->output, result) != 0) { printf("FAILURE (NormalizationTest.txt line %d):\n", test->linenum); - printf("input:\t%s\n", print_wchar_str(test->input)); - printf("expected:\t%s\n", print_wchar_str(test->output)); - printf("got\t%s\n", print_wchar_str(result)); + printf("input: %s\n", print_wchar_str(test->input)); + printf("expected: %s\n", print_wchar_str(test->output)); + printf("got: %s\n", print_wchar_str(result)); printf("\n"); exit(1); } -- 2.24.0

view thread (5+ messages)  latest in thread

Message-ID: <6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb@2ndquadrant.com>
Permalink:  ../6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb@2ndquadrant.com/
Also on:    postgresql.org/message-id/6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb@2ndquadrant.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com
  Subject: Re: Unicode normalization test broken output
  In-Reply-To: <6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb@2ndquadrant.com>
  References: <6a7a8516-7d11-8fbd-0e8b-eadb4f0679eb@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox