mktime: improve thread-safety
[gnulib.git] / tests / uninorm / test-u32-nfc-big.c
blob238f745645f2b31aa570eca76b4e06e5e8cba926
1 /* Test of Unicode compliance of canonical normalization of UTF-32 strings.
2 Copyright (C) 2009-2024 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
39 c2 == NFC(c1) == NFC(c2) == NFC(c3)
40 c4 == NFC(c4) == NFC(c5)
43 size_t length;
44 uint32_t *result;
46 result = u32_normalize (UNINORM_NFC, c1, c1_length, NULL, &length);
47 if (!(result != NULL
48 && length == c2_length
49 && u32_cmp (result, c2, c2_length) == 0))
50 return 1;
51 free (result);
54 size_t length;
55 uint32_t *result;
57 result = u32_normalize (UNINORM_NFC, c2, c2_length, NULL, &length);
58 if (!(result != NULL
59 && length == c2_length
60 && u32_cmp (result, c2, c2_length) == 0))
61 return 2;
62 free (result);
65 size_t length;
66 uint32_t *result;
68 result = u32_normalize (UNINORM_NFC, c3, c3_length, NULL, &length);
69 if (!(result != NULL
70 && length == c2_length
71 && u32_cmp (result, c2, c2_length) == 0))
72 return 3;
73 free (result);
76 size_t length;
77 uint32_t *result;
79 result = u32_normalize (UNINORM_NFC, c4, c4_length, NULL, &length);
80 if (!(result != NULL
81 && length == c4_length
82 && u32_cmp (result, c4, c4_length) == 0))
83 return 4;
84 free (result);
87 size_t length;
88 uint32_t *result;
90 result = u32_normalize (UNINORM_NFC, c5, c5_length, NULL, &length);
91 if (!(result != NULL
92 && length == c4_length
93 && u32_cmp (result, c4, c4_length) == 0))
94 return 5;
95 free (result);
97 return 0;
101 main (int argc, char *argv[])
103 struct normalization_test_file file;
105 read_normalization_test_file (argv[1], &file);
107 test_specific (&file, check);
108 test_other (&file, UNINORM_NFC);
110 free_normalization_test_file (&file);
112 return test_exit_status;
115 #else
117 #include <stdio.h>
120 main ()
122 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
123 return 77;
126 #endif