annotate tests/uninorm/test-u32-nfkc-big.c @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children 5b87a9bf7240
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of Unicode compliance of compatibility 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.
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
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/>. */
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
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
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include "uninorm.h"
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <stdlib.h>
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include "unistr.h"
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include "test-u32-normalize-big.h"
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 static int
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 check (const uint32_t *c1, size_t c1_length,
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 const uint32_t *c2, size_t c2_length,
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 const uint32_t *c3, size_t c3_length,
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 const uint32_t *c4, size_t c4_length,
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 const uint32_t *c5, size_t c5_length)
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 /* Check c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5). */
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 size_t length;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 uint32_t *result;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 result = u32_normalize (UNINORM_NFKC, c1, c1_length, NULL, &length);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
44 && length == c4_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
45 && u32_cmp (result, c4, c4_length) == 0))
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 return 1;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 free (result);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 size_t length;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 uint32_t *result;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 result = u32_normalize (UNINORM_NFKC, c2, c2_length, NULL, &length);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
55 && length == c4_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
56 && u32_cmp (result, c4, c4_length) == 0))
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 return 2;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 free (result);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 size_t length;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 uint32_t *result;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 result = u32_normalize (UNINORM_NFKC, c3, c3_length, NULL, &length);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
66 && length == c4_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
67 && u32_cmp (result, c4, c4_length) == 0))
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 return 3;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 free (result);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 size_t length;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 uint32_t *result;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 result = u32_normalize (UNINORM_NFKC, c4, c4_length, NULL, &length);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
77 && length == c4_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
78 && u32_cmp (result, c4, c4_length) == 0))
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 return 4;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 free (result);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 size_t length;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 uint32_t *result;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 result = u32_normalize (UNINORM_NFKC, c5, c5_length, NULL, &length);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 if (!(result != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
88 && length == c4_length
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11199
diff changeset
89 && u32_cmp (result, c4, c4_length) == 0))
11199
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 return 5;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 free (result);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 return 0;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 int
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 main (int argc, char *argv[])
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 struct normalization_test_file file;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 read_normalization_test_file (argv[1], &file);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 test_specific (&file, check);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 test_other (&file, UNINORM_NFKC);
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 return 0;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 #else
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 #include <stdio.h>
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 int
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 main ()
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 {
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 return 77;
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 }
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119
c9a58fa0ec8d Tests for module 'uninorm/nfkc'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 #endif