errno-h: document Haiku errors can’t be -1
[gnulib.git] / tests / uninorm / test-u32-nfkc-big.c
blob380f674cae85c096cb69a5e061b6708c08012ab6
1 /* Test of Unicode compliance of compatibility normalization of UTF-32 strings.
2 Copyright (C) 2009-2025 Free Software Foundation, Inc.
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.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
19 #include <config.h>
21 #if GNULIB_TEST_UNINORM_U32_NORMALIZE
23 #include "uninorm.h"
25 #include <stdlib.h>
27 #include "unistr.h"
28 #include "test-u32-normalize-big.h"
29 #include "macros.h"
31 static int
32 check (const uint32_t *c1, size_t c1_length,
33 const uint32_t *c2, size_t c2_length,
34 const uint32_t *c3, size_t c3_length,
35 const uint32_t *c4, size_t c4_length,
36 const uint32_t *c5, size_t c5_length)
38 /* Check c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5). */
40 size_t length;
41 uint32_t *result;
43 result = u32_normalize (UNINORM_NFKC, c1, c1_length, NULL, &length);
44 if (!(result != NULL
45 && length == c4_length
46 && u32_cmp (result, c4, c4_length) == 0))
47 return 1;
48 free (result);
51 size_t length;
52 uint32_t *result;
54 result = u32_normalize (UNINORM_NFKC, c2, c2_length, NULL, &length);
55 if (!(result != NULL
56 && length == c4_length
57 && u32_cmp (result, c4, c4_length) == 0))
58 return 2;
59 free (result);
62 size_t length;
63 uint32_t *result;
65 result = u32_normalize (UNINORM_NFKC, c3, c3_length, NULL, &length);
66 if (!(result != NULL
67 && length == c4_length
68 && u32_cmp (result, c4, c4_length) == 0))
69 return 3;
70 free (result);
73 size_t length;
74 uint32_t *result;
76 result = u32_normalize (UNINORM_NFKC, c4, c4_length, NULL, &length);
77 if (!(result != NULL
78 && length == c4_length
79 && u32_cmp (result, c4, c4_length) == 0))
80 return 4;
81 free (result);
84 size_t length;
85 uint32_t *result;
87 result = u32_normalize (UNINORM_NFKC, c5, c5_length, NULL, &length);
88 if (!(result != NULL
89 && length == c4_length
90 && u32_cmp (result, c4, c4_length) == 0))
91 return 5;
92 free (result);
94 return 0;
97 int
98 main (int argc, char *argv[])
100 struct normalization_test_file file;
102 read_normalization_test_file (argv[1], &file);
104 test_specific (&file, check);
105 test_other (&file, UNINORM_NFKC);
107 free_normalization_test_file (&file);
109 return test_exit_status;
112 #else
114 #include <stdio.h>
117 main ()
119 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
120 return 77;
123 #endif