diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2020-03-24 08:49:52 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2020-03-24 10:02:46 +0100 |
commit | d40d564c5a920e1121b28463dfed74441cbae5c0 (patch) | |
tree | 7a3cc5d8353896fb5abafeee9eaf63952beb2563 /src/common/unicode/norm_test.c | |
parent | cedffbdb8b137325a79e07a976457bc2314adf9b (diff) | |
download | postgresql-d40d564c5a920e1121b28463dfed74441cbae5c0.tar.gz postgresql-d40d564c5a920e1121b28463dfed74441cbae5c0.zip |
Add support for other normal forms to Unicode normalization API
It previously only supported NFKC, for use by SASLprep. This expands
the API to offer the choice of all four normalization forms. Right
now, there are no internal users of the forms other than NFKC.
Reviewed-by: Daniel Verite <daniel@manitou-mail.org>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Discussion: https://www.postgresql.org/message-id/flat/c1909f27-c269-2ed9-12f8-3ab72c8caf7a@2ndquadrant.com
Diffstat (limited to 'src/common/unicode/norm_test.c')
-rw-r--r-- | src/common/unicode/norm_test.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/common/unicode/norm_test.c b/src/common/unicode/norm_test.c index f6e8f0c0bb7..dde5d24349f 100644 --- a/src/common/unicode/norm_test.c +++ b/src/common/unicode/norm_test.c @@ -63,18 +63,21 @@ main(int argc, char **argv) for (test = UnicodeNormalizationTests; test->input[0] != 0; test++) { - pg_wchar *result; + for (int form = 0; form < 4; form++) + { + pg_wchar *result; - result = unicode_normalize_kc(test->input); + result = unicode_normalize(form, test->input); - if (pg_wcscmp(test->output, result) != 0) - { - printf("FAILURE (NormalizationTest.txt line %d):\n", test->linenum); - 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); + if (pg_wcscmp(test->output[form], result) != 0) + { + printf("FAILURE (NormalizationTest.txt line %d form %d):\n", test->linenum, form); + printf("input: %s\n", print_wchar_str(test->input)); + printf("expected: %s\n", print_wchar_str(test->output[form])); + printf("got: %s\n", print_wchar_str(result)); + printf("\n"); + exit(1); + } } } |