annotate tests/uninorm/test-u32-normalize-big.h @ 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 #include <stddef.h>
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 "unitypes.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include "uninorm.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 /* The NormalizationTest.txt is from www.unicode.org, with stripped comments:
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 sed -e 's| *#.*||' < .../ucd/NormalizationTest.txt \
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 > tests/uninorm/NormalizationTest.txt
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 It is only used to verify the compliance of this implementation of the
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 Unicode normalization forms. It is not used by the library code, only
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 by the unit tests. */
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 /* Representation of a line in the NormalizationTest.txt file. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 struct normalization_test_line
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 unsigned int lineno;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 uint32_t *sequences[5];
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 };
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 /* Representation of a delimited part of the NormalizationTest.txt file. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 struct normalization_test_part
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 struct normalization_test_line *lines;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 size_t lines_length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 };
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 /* Representation of the entire NormalizationTest.txt file. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 struct normalization_test_file
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 struct normalization_test_part parts[4];
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 /* The set of c1 values from part 1, sorted in ascending order, with a
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 sentinel value of 0x110000 at the end. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 ucs4_t *part1_c1_sorted;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 /* The filename of the NormalizationTest.txt file. */
40226
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
51 char *filename;
11193
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 /* Read the NormalizationTest.txt file and return its contents. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 extern void
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 read_normalization_test_file (const char *filename,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
57 struct normalization_test_file *file);
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 /* Perform the first compliance test. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 extern void
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 test_specific (const struct normalization_test_file *file,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
62 int (*check) (const uint32_t *c1, size_t c1_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
63 const uint32_t *c2, size_t c2_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
64 const uint32_t *c3, size_t c3_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
65 const uint32_t *c4, size_t c4_length,
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
66 const uint32_t *c5, size_t c5_length));
11193
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 /* Perform the second compliance test. */
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 extern void
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 test_other (const struct normalization_test_file *file, uninorm_t nf);
40226
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
71
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
72 /* Free the representation of the NormalizationTest.txt file. */
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
73 extern void
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
74 free_normalization_test_file (struct normalization_test_file *file);