spawn-pipe tests: Fix test failure with MSVC.
[gnulib.git] / tests / uninorm / test-u32-nfkd-big.c
blob7facec7e0be9f1cb3561c2804bdeb1778c1b1b45
1 /* Test of Unicode compliance of compatibility decomposition of UTF-32 strings.
2 Copyright (C) 2009-2020 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"
30 static int
31 check (const uint32_t *c1, size_t c1_length,
32 const uint32_t *c2, size_t c2_length,
33 const uint32_t *c3, size_t c3_length,
34 const uint32_t *c4, size_t c4_length,
35 const uint32_t *c5, size_t c5_length)
37 /* Check c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5). */
39 size_t length;
40 uint32_t *result;
42 result = u32_normalize (UNINORM_NFKD, c1, c1_length, NULL, &length);
43 if (!(result != NULL
44 && length == c5_length
45 && u32_cmp (result, c5, c5_length) == 0))
46 return 1;
47 free (result);
50 size_t length;
51 uint32_t *result;
53 result = u32_normalize (UNINORM_NFKD, c2, c2_length, NULL, &length);
54 if (!(result != NULL
55 && length == c5_length
56 && u32_cmp (result, c5, c5_length) == 0))
57 return 2;
58 free (result);
61 size_t length;
62 uint32_t *result;
64 result = u32_normalize (UNINORM_NFKD, c3, c3_length, NULL, &length);
65 if (!(result != NULL
66 && length == c5_length
67 && u32_cmp (result, c5, c5_length) == 0))
68 return 3;
69 free (result);
72 size_t length;
73 uint32_t *result;
75 result = u32_normalize (UNINORM_NFKD, c4, c4_length, NULL, &length);
76 if (!(result != NULL
77 && length == c5_length
78 && u32_cmp (result, c5, c5_length) == 0))
79 return 4;
80 free (result);
83 size_t length;
84 uint32_t *result;
86 result = u32_normalize (UNINORM_NFKD, c5, c5_length, NULL, &length);
87 if (!(result != NULL
88 && length == c5_length
89 && u32_cmp (result, c5, c5_length) == 0))
90 return 5;
91 free (result);
93 return 0;
96 int
97 main (int argc, char *argv[])
99 struct normalization_test_file file;
101 read_normalization_test_file (argv[1], &file);
103 test_specific (&file, check);
104 test_other (&file, UNINORM_NFKD);
106 free_normalization_test_file (&file);
108 return 0;
111 #else
113 #include <stdio.h>
116 main ()
118 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
119 return 77;
122 #endif