Tests for module 'unicase/toupper'.
authorBruno Haible <bruno@clisp.org>
Sun, 8 Feb 2009 20:24:51 +0000 (21:24 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 8 Feb 2009 20:24:51 +0000 (21:24 +0100)
ChangeLog
modules/unicase/toupper-tests [new file with mode: 0644]
tests/unicase/test-mapping-part1.h [new file with mode: 0644]
tests/unicase/test-mapping-part2.h [new file with mode: 0644]

index 2437436..0f45dcd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-02-08  Bruno Haible  <bruno@clisp.org>
 
+       Tests for module 'unicase/toupper'.
+       * modules/unicase/toupper-tests: New file.
+       * tests/unicase/test-mapping-part1.h: New file.
+       * tests/unicase/test-mapping-part2.h: New file.
+
        New module 'unicase/totitle'.
        * modules/unicase/totitle: New file.
        * lib/unicase/totitle.c: New file.
diff --git a/modules/unicase/toupper-tests b/modules/unicase/toupper-tests
new file mode 100644 (file)
index 0000000..93adf9a
--- /dev/null
@@ -0,0 +1,14 @@
+Files:
+tests/unicase/test-uc_toupper.c
+tests/unicase/test-mapping-part1.h
+tests/unicase/test-mapping-part2.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-uc_toupper
+check_PROGRAMS += test-uc_toupper
+test_uc_toupper_SOURCES = unicase/test-uc_toupper.c
+
diff --git a/tests/unicase/test-mapping-part1.h b/tests/unicase/test-mapping-part1.h
new file mode 100644 (file)
index 0000000..4b7ac8e
--- /dev/null
@@ -0,0 +1,45 @@
+/* Test of single character case mapping functions.
+   Copyright (C) 2007-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/>.  */
+
+#include <config.h>
+
+#include "unicase.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ASSERT(expr) \
+  do                                                                        \
+    {                                                                       \
+      if (!(expr))                                                          \
+        {                                                                   \
+          fprintf (stderr, "%s:%d: assertion failed for c = 0x%04X\n",      \
+                  __FILE__, __LINE__, c);                                   \
+          fflush (stderr);                                                  \
+          abort ();                                                         \
+        }                                                                   \
+    }                                                                       \
+  while (0)
+#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
+
+/* Pair of Unicode characters.  */
+typedef struct { ucs4_t ch; ucs4_t value; } pair_t;
+
+/* Characters and their mapping values, ignoring no-op mappings, in increasing
+   order.  */
+static const pair_t mapping[] =
+  {
diff --git a/tests/unicase/test-mapping-part2.h b/tests/unicase/test-mapping-part2.h
new file mode 100644 (file)
index 0000000..ef43cdd
--- /dev/null
@@ -0,0 +1,37 @@
+/* Test of single character case mapping functions.
+   Copyright (C) 2007-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/>.  */
+
+  };
+
+int
+main ()
+{
+  unsigned int c;
+  size_t i;
+
+  c = 0;
+  for (i = 0; i < SIZEOF (mapping); i++)
+    {
+      for (; c < mapping[i].ch; c++)
+       ASSERT (MAP (c) == c);
+      ASSERT (MAP (c) == mapping[i].value);
+      c++;
+    }
+  for (; c < 0x110000; c++)
+    ASSERT (MAP (c) == c);
+
+  return 0;
+}