Mercurial > hg > octave-lyh > gnulib-hg
changeset 11146:6cf2f8dbf056
Tests for module 'unicase/toupper'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 08 Feb 2009 21:24:51 +0100 |
parents | 33928cb804c4 |
children | 8c524cd9920b |
files | ChangeLog modules/unicase/toupper-tests tests/unicase/test-mapping-part1.h tests/unicase/test-mapping-part2.h |
diffstat | 4 files changed, 101 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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.
new file mode 100644 --- /dev/null +++ b/modules/unicase/toupper-tests @@ -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 +
new file mode 100644 --- /dev/null +++ b/tests/unicase/test-mapping-part1.h @@ -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[] = + {
new file mode 100644 --- /dev/null +++ b/tests/unicase/test-mapping-part2.h @@ -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; +}