annotate tests/uninorm/test-u32-nfc-big.c @ 12421:e8d2c6fc33ad

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