Mercurial > hg > octave-kai > gnulib-hg
changeset 11305:0483174037b1
Tests for module 'unicase/locale-language'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 08 Mar 2009 14:13:39 +0100 |
parents | a2786ccc7dbc |
children | 58187acb6506 |
files | ChangeLog modules/unicase/locale-language-tests tests/unicase/test-locale-language.c tests/unicase/test-locale-language.sh |
diffstat | 4 files changed, 114 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-03-08 Bruno Haible <bruno@clisp.org> + Tests for module 'unicase/locale-language'. + * modules/unicase/locale-language-tests: New file. + * tests/unicase/test-locale-language.sh: New file. + * tests/unicase/test-locale-language.c: New file. + New module 'unicase/locale-language'. * lib/unicase/locale-language.c: New file. * lib/unicase/locale-languages.gperf: New file.
new file mode 100644 --- /dev/null +++ b/modules/unicase/locale-language-tests @@ -0,0 +1,23 @@ +Files: +tests/unicase/test-locale-language.sh +tests/unicase/test-locale-language.c +m4/locale-fr.m4 +m4/locale-ja.m4 +m4/locale-tr.m4 +m4/locale-zh.m4 +m4/codeset.m4 + +Depends-on: + +configure.ac: +gt_LOCALE_FR +gt_LOCALE_FR_UTF8 +gt_LOCALE_JA +gt_LOCALE_TR_UTF8 +gt_LOCALE_ZH_CN + +Makefile.am: +TESTS += unicase/test-locale-language.sh +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_JA='@LOCALE_JA@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-locale-language +test_locale_language_SOURCES = unicase/test-locale-language.c
new file mode 100644 --- /dev/null +++ b/tests/unicase/test-locale-language.c @@ -0,0 +1,56 @@ +/* Test of language code determination. + 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/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2009. */ + +#include <config.h> + +#include "unicase.h" + +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + fflush (stderr); \ + abort (); \ + } \ + } \ + while (0) + +int +main (int argc, char *argv[]) +{ + const char *expected; + const char *language; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + expected = argv[1]; + + language = uc_locale_language (); + ASSERT (strcmp (language, expected) == 0); + + return 0; +}
new file mode 100755 --- /dev/null +++ b/tests/unicase/test-locale-language.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +LC_ALL=C ./test-locale-language${EXEEXT} '' || exit 1 + +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ./test-locale-language${EXEEXT} fr || exit 1 +fi + +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ./test-locale-language${EXEEXT} fr || exit 1 +fi + +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA ./test-locale-language${EXEEXT} ja || exit 1 +fi + +: ${LOCALE_TR_UTF8=tr_TR.UTF-8} +if test $LOCALE_TR_UTF8 != none; then + LC_ALL=$LOCALE_TR_UTF8 ./test-locale-language${EXEEXT} tr || exit 1 +fi + +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN ./test-locale-language${EXEEXT} zh || exit 1 +fi + +exit 0