From: Bruno Haible Date: Sat, 21 Feb 2009 11:26:45 +0000 (+0100) Subject: Tests for module 'uninorm/canonical-decomposition'. X-Git-Tag: v0.1~6304 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=293d2d3a78e857200782c941833111d6c8322b02;p=gnulib.git Tests for module 'uninorm/canonical-decomposition'. --- diff --git a/ChangeLog b/ChangeLog index 95878fe6f..9c8a77037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-02-21 Bruno Haible + Tests for module 'uninorm/canonical-decomposition'. + * tests/uninorm/test-canonical-decomposition.c: New file. + * modules/uninorm/canonical-decomposition-tests: New file. + New module 'uninorm/canonical-decomposition'. * lib/uninorm/canonical-decomposition.c: New file. * modules/uninorm/canonical-decomposition: New file. diff --git a/modules/uninorm/canonical-decomposition-tests b/modules/uninorm/canonical-decomposition-tests new file mode 100644 index 000000000..5ec587e21 --- /dev/null +++ b/modules/uninorm/canonical-decomposition-tests @@ -0,0 +1,12 @@ +Files: +tests/uninorm/test-canonical-decomposition.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-canonical-decomposition +check_PROGRAMS += test-canonical-decomposition +test_canonical_decomposition_SOURCES = uninorm/test-canonical-decomposition.c + diff --git a/tests/uninorm/test-canonical-decomposition.c b/tests/uninorm/test-canonical-decomposition.c new file mode 100644 index 000000000..59061c94e --- /dev/null +++ b/tests/uninorm/test-canonical-decomposition.c @@ -0,0 +1,148 @@ +/* Test of canonical decomposition of Unicode characters. + 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +#include "uninorm.h" + +#include +#include + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + fflush (stderr); \ + abort (); \ + } \ + } \ + while (0) + +int +main () +{ + ucs4_t decomposed[UC_DECOMPOSITION_MAX_LENGTH]; + int ret; + + /* SPACE */ + ret = uc_canonical_decomposition (0x0020, decomposed); + ASSERT (ret == -1); + + /* LATIN CAPITAL LETTER A WITH DIAERESIS */ + ret = uc_canonical_decomposition (0x00C4, decomposed); + ASSERT (ret == 2); + ASSERT (decomposed[0] == 0x0041); + ASSERT (decomposed[1] == 0x0308); + + /* LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON */ + ret = uc_canonical_decomposition (0x01DE, decomposed); + ASSERT (ret == 2); + ASSERT (decomposed[0] == 0x00C4); + ASSERT (decomposed[1] == 0x0304); + + /* GREEK DIALYTIKA AND PERISPOMENI */ + ret = uc_canonical_decomposition (0x1FC1, decomposed); + ASSERT (ret == 2); + ASSERT (decomposed[0] == 0x00A8); + ASSERT (decomposed[1] == 0x0342); + + /* SCRIPT SMALL L */ + ret = uc_canonical_decomposition (0x2113, decomposed); + ASSERT (ret == -1); + + /* NO-BREAK SPACE */ + ret = uc_canonical_decomposition (0x00A0, decomposed); + ASSERT (ret == -1); + + /* ARABIC LETTER VEH INITIAL FORM */ + ret = uc_canonical_decomposition (0xFB6C, decomposed); + ASSERT (ret == -1); + + /* ARABIC LETTER VEH MEDIAL FORM */ + ret = uc_canonical_decomposition (0xFB6D, decomposed); + ASSERT (ret == -1); + + /* ARABIC LETTER VEH FINAL FORM */ + ret = uc_canonical_decomposition (0xFB6B, decomposed); + ASSERT (ret == -1); + + /* ARABIC LETTER VEH ISOLATED FORM */ + ret = uc_canonical_decomposition (0xFB6A, decomposed); + ASSERT (ret == -1); + + /* CIRCLED NUMBER FIFTEEN */ + ret = uc_canonical_decomposition (0x246E, decomposed); + ASSERT (ret == -1); + + /* TRADE MARK SIGN */ + ret = uc_canonical_decomposition (0x2122, decomposed); + ASSERT (ret == -1); + + /* LATIN SUBSCRIPT SMALL LETTER I */ + ret = uc_canonical_decomposition (0x1D62, decomposed); + ASSERT (ret == -1); + + /* PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS */ + ret = uc_canonical_decomposition (0xFE35, decomposed); + ASSERT (ret == -1); + + /* FULLWIDTH LATIN CAPITAL LETTER A */ + ret = uc_canonical_decomposition (0xFF21, decomposed); + ASSERT (ret == -1); + + /* HALFWIDTH IDEOGRAPHIC COMMA */ + ret = uc_canonical_decomposition (0xFF64, decomposed); + ASSERT (ret == -1); + + /* SMALL IDEOGRAPHIC COMMA */ + ret = uc_canonical_decomposition (0xFE51, decomposed); + ASSERT (ret == -1); + + /* SQUARE MHZ */ + ret = uc_canonical_decomposition (0x3392, decomposed); + ASSERT (ret == -1); + + /* VULGAR FRACTION THREE EIGHTHS */ + ret = uc_canonical_decomposition (0x215C, decomposed); + ASSERT (ret == -1); + + /* MICRO SIGN */ + ret = uc_canonical_decomposition (0x00B5, decomposed); + ASSERT (ret == -1); + + /* ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM */ + ret = uc_canonical_decomposition (0xFDFA, decomposed); + ASSERT (ret == -1); + + /* HANGUL SYLLABLE GEUL */ + ret = uc_canonical_decomposition (0xAE00, decomposed); + ASSERT (ret == 3); + ASSERT (decomposed[0] == 0x1100); + ASSERT (decomposed[1] == 0x1173); + ASSERT (decomposed[2] == 0x11AF); + + /* HANGUL SYLLABLE GEU */ + ret = uc_canonical_decomposition (0xADF8, decomposed); + ASSERT (ret == 2); + ASSERT (decomposed[0] == 0x1100); + ASSERT (decomposed[1] == 0x1173); + + return 0; +}