annotate tests/uninorm/test-u32-nfd-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 canonical decomposition 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
13073
03de1efbfdd3 Resolve conflict between the two kinds of module indicators.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
21 #if GNULIB_TEST_UNINORM_U32_NORMALIZE
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include "uninorm.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <stdlib.h>
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include "unistr.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include "test-u32-normalize-big.h"
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 static int
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 check (const uint32_t *c1, size_t c1_length,
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 const uint32_t *c2, size_t c2_length,
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 const uint32_t *c3, size_t c3_length,
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 const uint32_t *c4, size_t c4_length,
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 const uint32_t *c5, size_t c5_length)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 /* Check
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 c3 == NFD(c1) == NFD(c2) == NFD(c3)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 c5 == NFD(c4) == NFD(c5)
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 */
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 size_t length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 uint32_t *result;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 result = u32_normalize (UNINORM_NFD, c1, c1_length, NULL, &length);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
47 && length == c3_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
48 && u32_cmp (result, c3, c3_length) == 0))
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 return 1;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 free (result);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 }
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 size_t length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 uint32_t *result;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 result = u32_normalize (UNINORM_NFD, c2, c2_length, NULL, &length);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
58 && length == c3_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
59 && u32_cmp (result, c3, c3_length) == 0))
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 return 2;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 free (result);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 size_t length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 uint32_t *result;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 result = u32_normalize (UNINORM_NFD, c3, c3_length, NULL, &length);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
69 && length == c3_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
70 && u32_cmp (result, c3, c3_length) == 0))
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 return 3;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 free (result);
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 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 size_t length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 uint32_t *result;
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 result = u32_normalize (UNINORM_NFD, c4, c4_length, NULL, &length);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
80 && length == c5_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
81 && u32_cmp (result, c5, c5_length) == 0))
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 return 4;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 free (result);
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 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 size_t length;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 uint32_t *result;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 result = u32_normalize (UNINORM_NFD, c5, c5_length, NULL, &length);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
91 && length == c5_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11193
diff changeset
92 && u32_cmp (result, c5, c5_length) == 0))
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 return 5;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 free (result);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 return 0;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 int
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 main (int argc, char *argv[])
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 struct normalization_test_file file;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 read_normalization_test_file (argv[1], &file);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 test_specific (&file, check);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 test_other (&file, UNINORM_NFD);
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108
40226
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
109 free_normalization_test_file (&file);
5b87a9bf7240 uninorm tests: Free allocated memory.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
110
11193
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 return 0;
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
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 #else
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 #include <stdio.h>
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 int
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 main ()
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 {
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 return 77;
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 }
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124
531b88e0986f Tests for module 'uninorm/nfd'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 #endif