spawn-pipe tests: Fix test failure with MSVC.
[gnulib.git] / tests / uninorm / test-u32-nfc-big.c
blobc4dace1dd7c75c0b14d807facd625a88f7e468b3
1 /* Test of Unicode compliance of canonical normalization 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
38 c2 == NFC(c1) == NFC(c2) == NFC(c3)
39 c4 == NFC(c4) == NFC(c5)
42 size_t length;
43 uint32_t *result;
45 result = u32_normalize (UNINORM_NFC, c1, c1_length, NULL, &length);
46 if (!(result != NULL
47 && length == c2_length
48 && u32_cmp (result, c2, c2_length) == 0))
49 return 1;
50 free (result);
53 size_t length;
54 uint32_t *result;
56 result = u32_normalize (UNINORM_NFC, c2, c2_length, NULL, &length);
57 if (!(result != NULL
58 && length == c2_length
59 && u32_cmp (result, c2, c2_length) == 0))
60 return 2;
61 free (result);
64 size_t length;
65 uint32_t *result;
67 result = u32_normalize (UNINORM_NFC, c3, c3_length, NULL, &length);
68 if (!(result != NULL
69 && length == c2_length
70 && u32_cmp (result, c2, c2_length) == 0))
71 return 3;
72 free (result);
75 size_t length;
76 uint32_t *result;
78 result = u32_normalize (UNINORM_NFC, c4, c4_length, NULL, &length);
79 if (!(result != NULL
80 && length == c4_length
81 && u32_cmp (result, c4, c4_length) == 0))
82 return 4;
83 free (result);
86 size_t length;
87 uint32_t *result;
89 result = u32_normalize (UNINORM_NFC, c5, c5_length, NULL, &length);
90 if (!(result != NULL
91 && length == c4_length
92 && u32_cmp (result, c4, c4_length) == 0))
93 return 5;
94 free (result);
96 return 0;
99 int
100 main (int argc, char *argv[])
102 struct normalization_test_file file;
104 read_normalization_test_file (argv[1], &file);
106 test_specific (&file, check);
107 test_other (&file, UNINORM_NFC);
109 free_normalization_test_file (&file);
111 return 0;
114 #else
116 #include <stdio.h>
119 main ()
121 fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
122 return 77;
125 #endif