summaryrefslogtreecommitdiff
path: root/tests/uninorm/test-u32-nfd-big.c
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2009-09-14 12:32:44 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2009-09-14 12:32:44 +0200
commitfa095a4504cbe668e4244547e2c141597bea4ecf (patch)
tree06135820a286ffec47804e75fbf8a147e92acd2e /tests/uninorm/test-u32-nfd-big.c
Imported Upstream version 0.9.1upstream/0.9.1
Diffstat (limited to 'tests/uninorm/test-u32-nfd-big.c')
-rw-r--r--tests/uninorm/test-u32-nfd-big.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/uninorm/test-u32-nfd-big.c b/tests/uninorm/test-u32-nfd-big.c
new file mode 100644
index 0000000..9bfd0d8
--- /dev/null
+++ b/tests/uninorm/test-u32-nfd-big.c
@@ -0,0 +1,125 @@
+/* Test of Unicode compliance of canonical decomposition of UTF-32 strings.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2009. */
+
+#include <config.h>
+
+#if GNULIB_UNINORM_U32_NORMALIZE
+
+#include "uninorm.h"
+
+#include <stdlib.h>
+
+#include "unistr.h"
+#include "progname.h"
+#include "test-u32-normalize-big.h"
+
+static int
+check (const uint32_t *c1, size_t c1_length,
+ const uint32_t *c2, size_t c2_length,
+ const uint32_t *c3, size_t c3_length,
+ const uint32_t *c4, size_t c4_length,
+ const uint32_t *c5, size_t c5_length)
+{
+ /* Check
+ c3 == NFD(c1) == NFD(c2) == NFD(c3)
+ c5 == NFD(c4) == NFD(c5)
+ */
+ {
+ size_t length;
+ uint32_t *result;
+
+ result = u32_normalize (UNINORM_NFD, c1, c1_length, NULL, &length);
+ if (!(result != NULL
+ && length == c3_length
+ && u32_cmp (result, c3, c3_length) == 0))
+ return 1;
+ free (result);
+ }
+ {
+ size_t length;
+ uint32_t *result;
+
+ result = u32_normalize (UNINORM_NFD, c2, c2_length, NULL, &length);
+ if (!(result != NULL
+ && length == c3_length
+ && u32_cmp (result, c3, c3_length) == 0))
+ return 2;
+ free (result);
+ }
+ {
+ size_t length;
+ uint32_t *result;
+
+ result = u32_normalize (UNINORM_NFD, c3, c3_length, NULL, &length);
+ if (!(result != NULL
+ && length == c3_length
+ && u32_cmp (result, c3, c3_length) == 0))
+ return 3;
+ free (result);
+ }
+ {
+ size_t length;
+ uint32_t *result;
+
+ result = u32_normalize (UNINORM_NFD, c4, c4_length, NULL, &length);
+ if (!(result != NULL
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
+ return 4;
+ free (result);
+ }
+ {
+ size_t length;
+ uint32_t *result;
+
+ result = u32_normalize (UNINORM_NFD, c5, c5_length, NULL, &length);
+ if (!(result != NULL
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
+ return 5;
+ free (result);
+ }
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ struct normalization_test_file file;
+
+ set_program_name (argv[0]);
+ read_normalization_test_file (argv[1], &file);
+
+ test_specific (&file, check);
+ test_other (&file, UNINORM_NFD);
+
+ return 0;
+}
+
+#else
+
+#include <stdio.h>
+
+int
+main ()
+{
+ fprintf (stderr, "Skipping test: uninorm/u32-normalize module not included.\n");
+ return 77;
+}
+
+#endif