annotate tests/uninorm/test-u32-normalize-big.c @ 40226:5b87a9bf7240

uninorm tests: Free allocated memory. * tests/uninorm/test-u32-normalize-big.h (struct normalization_test_file): Remove 'const' from allocated member. (free_normalization_test_file): New declaration. * tests/uninorm/test-u32-normalize-big.c (test_other): Free allocated memory. (free_normalization_test_file): New function. * tests/uninorm/test-u32-nfc-big.c (main): Free allocated 'struct normalization_test_file' contents. * tests/uninorm/test-u32-nfd-big.c (main): Likewise. * tests/uninorm/test-u32-nfkc-big.c (main): Likewise. * tests/uninorm/test-u32-nfkd-big.c (main): Likewise.
author Bruno Haible <bruno@clisp.org>
date Sun, 10 Mar 2019 15:14:01 +0100
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of Unicode compliance of normalization of UTF-32 strings.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 /* Specification. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include "test-u32-normalize-big.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
13073
03de1efbfdd3 Resolve conflict between the two kinds of module indicators.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
24 #if GNULIB_TEST_UNINORM_U32_NORMALIZE
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include <stdio.h>
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <stdlib.h>
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #include "xalloc.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #include "unistr.h"
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12421
diff changeset
31 #include "macros.h"
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 #define ASSERT_WITH_LINE(expr, file, line) \
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
34 do \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
35 { \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
36 if (!(expr)) \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
37 { \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
38 fprintf (stderr, "%s:%d: assertion failed for %s:%u\n", \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
39 __FILE__, __LINE__, file, line); \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
40 fflush (stderr); \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
41 abort (); \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
42 } \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
43 } \
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 while (0)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 static int
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 cmp_ucs4_t (const void *a, const void *b)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 ucs4_t a_value = *(const ucs4_t *)a;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 ucs4_t b_value = *(const ucs4_t *)b;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 return (a_value < b_value ? -1 : a_value > b_value ? 1 : 0);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 void
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 read_normalization_test_file (const char *filename,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
56 struct normalization_test_file *file)
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 FILE *stream;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 unsigned int lineno;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 int part_index;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 struct normalization_test_line *lines;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 size_t lines_length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 size_t lines_allocated;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 stream = fopen (filename, "r");
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 if (stream == NULL)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 fprintf (stderr, "error during fopen of '%s'\n", filename);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 exit (1);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 for (part_index = 0; part_index < 4; part_index++)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 file->parts[part_index].lines = NULL;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 file->parts[part_index].lines_length = 0;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 lineno = 0;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 part_index = -1;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 lines = NULL;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 lines_length = 0;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 lines_allocated = 0;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 for (;;)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 char buf[1000+1];
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 char *ptr;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 int c;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 struct normalization_test_line line;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 size_t sequence_index;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 lineno++;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 /* Read a line. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 ptr = buf;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 do
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
98 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
99 c = getc (stream);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
100 if (c == EOF || c == '\n')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
101 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
102 *ptr++ = c;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
103 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 while (ptr < buf + 1000);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 *ptr = '\0';
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 if (c == EOF)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
107 break;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 /* Ignore empty lines and comment lines. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 if (buf[0] == '\0' || buf[0] == '#')
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
111 continue;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 /* Handle lines that introduce a new part. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 if (buf[0] == '@')
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
115 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
116 /* Switch to the next part. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
117 if (part_index >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
118 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
119 lines =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
120 (struct normalization_test_line *)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
121 xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
122 file->parts[part_index].lines = lines;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
123 file->parts[part_index].lines_length = lines_length;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
124 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
125 part_index++;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
126 lines = NULL;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
127 lines_length = 0;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
128 lines_allocated = 0;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
129 continue;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
130 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 /* It's a line containing 5 sequences of Unicode characters.
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
133 Parse it and append it to the current part. */
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 if (!(part_index >= 0 && part_index < 4))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
135 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
136 fprintf (stderr, "unexpected structure of '%s'\n", filename);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
137 exit (1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
138 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 ptr = buf;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 line.lineno = lineno;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 for (sequence_index = 0; sequence_index < 5; sequence_index++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
142 line.sequences[sequence_index] = NULL;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 for (sequence_index = 0; sequence_index < 5; sequence_index++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
144 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
145 uint32_t *sequence = XNMALLOC (1, uint32_t);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
146 size_t sequence_length = 0;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
148 for (;;)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
149 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
150 char *endptr;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
151 unsigned int uc;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
153 uc = strtoul (ptr, &endptr, 16);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
154 if (endptr == ptr)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
155 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
156 ptr = endptr;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
158 /* Append uc to the sequence. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
159 sequence =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
160 (uint32_t *)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
161 xnrealloc (sequence, sequence_length + 2, sizeof (uint32_t));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
162 sequence[sequence_length] = uc;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
163 sequence_length++;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
165 if (*ptr == ' ')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
166 ptr++;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
167 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
168 if (sequence_length == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
169 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
170 fprintf (stderr, "empty character sequence in '%s'\n", filename);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
171 exit (1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
172 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
173 sequence[sequence_length] = 0; /* terminator */
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
175 line.sequences[sequence_index] = sequence;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
177 if (*ptr != ';')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
178 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
179 fprintf (stderr, "error parsing '%s'\n", filename);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
180 exit (1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
181 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
182 ptr++;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
183 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 /* Append the line to the current part. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186 if (lines_length == lines_allocated)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
187 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
188 lines_allocated = 2 * lines_allocated;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
189 if (lines_allocated < 7)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
190 lines_allocated = 7;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
191 lines =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
192 (struct normalization_test_line *)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
193 xnrealloc (lines, lines_allocated, sizeof (struct normalization_test_line));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
194 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195 lines[lines_length] = line;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 lines_length++;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 if (part_index >= 0)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 lines =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
202 (struct normalization_test_line *)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
203 xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 file->parts[part_index].lines = lines;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 file->parts[part_index].lines_length = lines_length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 /* Collect all c1 values from the part 1 in an array. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 const struct normalization_test_part *p = &file->parts[1];
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 ucs4_t *c1_array = XNMALLOC (p->lines_length + 1, ucs4_t);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 size_t line_index;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 for (line_index = 0; line_index < p->lines_length; line_index++)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
216 const uint32_t *sequence = p->lines[line_index].sequences[0];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
217 /* In part 1, every sequences[0] consists of a single character. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
218 if (!(sequence[0] != 0 && sequence[1] == 0))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
219 abort ();
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
220 c1_array[line_index] = sequence[0];
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 /* Sort this array. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 qsort (c1_array, p->lines_length, sizeof (ucs4_t), cmp_ucs4_t);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 /* Add the sentinel at the end. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 c1_array[p->lines_length] = 0x110000;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229 file->part1_c1_sorted = c1_array;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 file->filename = xstrdup (filename);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 if (ferror (stream) || fclose (stream))
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 fprintf (stderr, "error reading from '%s'\n", filename);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 exit (1);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 void
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 test_specific (const struct normalization_test_file *file,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
243 int (*check) (const uint32_t *c1, size_t c1_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
244 const uint32_t *c2, size_t c2_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
245 const uint32_t *c3, size_t c3_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
246 const uint32_t *c4, size_t c4_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
247 const uint32_t *c5, size_t c5_length))
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 size_t part_index;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 for (part_index = 0; part_index < 4; part_index++)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 const struct normalization_test_part *p = &file->parts[part_index];
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 size_t line_index;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 for (line_index = 0; line_index < p->lines_length; line_index++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
257 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
258 const struct normalization_test_line *l = &p->lines[line_index];
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
260 ASSERT_WITH_LINE (check (l->sequences[0], u32_strlen (l->sequences[0]),
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
261 l->sequences[1], u32_strlen (l->sequences[1]),
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
262 l->sequences[2], u32_strlen (l->sequences[2]),
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
263 l->sequences[3], u32_strlen (l->sequences[3]),
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
264 l->sequences[4], u32_strlen (l->sequences[4]))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
265 == 0,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
266 file->filename, l->lineno);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
267 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 void
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 test_other (const struct normalization_test_file *file, uninorm_t nf)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 /* Check that for every character not listed in part 1 of the
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 NormalizationTest.txt file, the character maps to itself in each
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 of the four normalization forms. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 const ucs4_t *p = file->part1_c1_sorted;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 ucs4_t uc;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 for (uc = 0; uc < 0x110000; uc++)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 if (uc >= 0xD800 && uc < 0xE000)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
283 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
284 /* A surrogate, not a character. Skip uc. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
285 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 else if (uc == *p)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
287 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
288 /* Skip uc. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
289 p++;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
290 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
292 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
293 uint32_t input[1];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
294 size_t length;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
295 uint32_t *result;
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
297 input[0] = uc;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
298 result = u32_normalize (nf, input, 1, NULL, &length);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
299 ASSERT (result != NULL && length == 1 && result[0] == uc);
40226
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
300
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
301 free (result);
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11488
diff changeset
302 }
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305
40226
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
306 void
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
307 free_normalization_test_file (struct normalization_test_file *file)
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
308 {
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
309 size_t part_index;
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
310
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
311 for (part_index = 0; part_index < 4; part_index++)
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
312 {
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
313 const struct normalization_test_part *p = &file->parts[part_index];
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
314 size_t line_index;
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
315
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
316 for (line_index = 0; line_index < p->lines_length; line_index++)
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
317 {
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
318 const struct normalization_test_line *l = &p->lines[line_index];
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
319 size_t sequence_index;
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
320
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
321 for (sequence_index = 0; sequence_index < 5; sequence_index++)
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
322 free (l->sequences[sequence_index]);
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
323 }
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
324 free (p->lines);
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
325 }
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
326 free (file->part1_c1_sorted);
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
327 free (file->filename);
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
328 }
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
329
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
330 #endif