d66615d3dc7ad59120844e107d129ddde9a4a2a3
[gnulib.git] / tests / uninorm / test-u32-normalize-big.h
1 /* Test of Unicode compliance of normalization of UTF-32 strings.
2    Copyright (C) 2009-2012 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 #include <stddef.h>
18
19 #include "unitypes.h"
20 #include "uninorm.h"
21
22 /* The NormalizationTest.txt is from www.unicode.org, with stripped comments:
23      sed -e 's| *#.*||' < .../ucd/NormalizationTest.txt \
24                         > tests/uninorm/NormalizationTest.txt
25    It is only used to verify the compliance of this implementation of the
26    Unicode normalization forms.  It is not used by the library code, only
27    by the unit tests.  */
28
29 /* Representation of a line in the NormalizationTest.txt file.  */
30 struct normalization_test_line
31 {
32   unsigned int lineno;
33   uint32_t *sequences[5];
34 };
35
36 /* Representation of a delimited part of the NormalizationTest.txt file.  */
37 struct normalization_test_part
38 {
39   struct normalization_test_line *lines;
40   size_t lines_length;
41 };
42
43 /* Representation of the entire NormalizationTest.txt file.  */
44 struct normalization_test_file
45 {
46   struct normalization_test_part parts[4];
47   /* The set of c1 values from part 1, sorted in ascending order, with a
48      sentinel value of 0x110000 at the end.  */
49   ucs4_t *part1_c1_sorted;
50   /* The filename of the NormalizationTest.txt file.  */
51   const char *filename;
52 };
53
54 /* Read the NormalizationTest.txt file and return its contents.  */
55 extern void
56        read_normalization_test_file (const char *filename,
57                                      struct normalization_test_file *file);
58
59 /* Perform the first compliance test.  */
60 extern void
61        test_specific (const struct normalization_test_file *file,
62                       int (*check) (const uint32_t *c1, size_t c1_length,
63                                     const uint32_t *c2, size_t c2_length,
64                                     const uint32_t *c3, size_t c3_length,
65                                     const uint32_t *c4, size_t c4_length,
66                                     const uint32_t *c5, size_t c5_length));
67
68 /* Perform the second compliance test.  */
69 extern void
70        test_other (const struct normalization_test_file *file, uninorm_t nf);