From 611869be9f1083e53305446d90a2909fc89914ef Mon Sep 17 00:00:00 2001 From: Bruno Haible
Date: Mon, 13 Jan 2020 00:17:47 +0100 Subject: [PATCH 2/2] c32stombs: Add tests. * tests/test-c32stombs.c: New file, based on tests/test-c32srtombs.c. * tests/test-c32stombs-1.sh: New file, based on tests/test-c32srtombs-1.sh. * tests/test-c32stombs-2.sh: New file, based on tests/test-c32srtombs-2.sh. * tests/test-c32stombs-3.sh: New file, based on tests/test-c32srtombs-3.sh. * tests/test-c32stombs-4.sh: New file, based on tests/test-c32srtombs-4.sh. * modules/c32stombs-tests: New file, based on modules/c32srtombs-tests. --- ChangeLog | 12 ++++ modules/c32stombs-tests | 32 +++++++++ tests/test-c32stombs-1.sh | 15 ++++ tests/test-c32stombs-2.sh | 15 ++++ tests/test-c32stombs-3.sh | 15 ++++ tests/test-c32stombs-4.sh | 15 ++++ tests/test-c32stombs.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 281 insertions(+) create mode 100644 modules/c32stombs-tests create mode 100755 tests/test-c32stombs-1.sh create mode 100755 tests/test-c32stombs-2.sh create mode 100755 tests/test-c32stombs-3.sh create mode 100755 tests/test-c32stombs-4.sh create mode 100644 tests/test-c32stombs.c diff --git a/ChangeLog b/ChangeLog index c2f4f24..245f2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2020-01-12 Bruno Haible + c32stombs: Add tests. + * tests/test-c32stombs.c: New file, based on tests/test-c32srtombs.c. + * tests/test-c32stombs-1.sh: New file, based on + tests/test-c32srtombs-1.sh. + * tests/test-c32stombs-2.sh: New file, based on + tests/test-c32srtombs-2.sh. + * tests/test-c32stombs-3.sh: New file, based on + tests/test-c32srtombs-3.sh. + * tests/test-c32stombs-4.sh: New file, based on + tests/test-c32srtombs-4.sh. + * modules/c32stombs-tests: New file, based on modules/c32srtombs-tests. + c32stombs: New module. * lib/uchar.in.h (c32stombs): New declaration. * lib/c32stombs.c: New file. diff --git a/modules/c32stombs-tests b/modules/c32stombs-tests new file mode 100644 index 0000000..c96de03 --- /dev/null +++ b/modules/c32stombs-tests @@ -0,0 +1,32 @@ +Files: +tests/test-c32stombs-1.sh +tests/test-c32stombs-2.sh +tests/test-c32stombs-3.sh +tests/test-c32stombs-4.sh +tests/test-c32stombs.c +tests/signature.h +tests/macros.h +m4/locale-fr.m4 +m4/locale-ja.m4 +m4/locale-zh.m4 +m4/codeset.m4 + +Depends-on: +setlocale +mbstoc32s + +configure.ac: +gt_LOCALE_FR +gt_LOCALE_FR_UTF8 +gt_LOCALE_JA +gt_LOCALE_ZH_CN + +Makefile.am: +TESTS += test-c32stombs-1.sh test-c32stombs-2.sh test-c32stombs-3.sh test-c32stombs-4.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32stombs +test_c32stombs_LDADD = $(LDADD) $(LIB_SETLOCALE) diff --git a/tests/test-c32stombs-1.sh b/tests/test-c32stombs-1.sh new file mode 100755 index 0000000..ea63e9a --- /dev/null +++ b/tests/test-c32stombs-1.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: ${LOCALE_FR=fr_FR} +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-c32stombs${EXEEXT} 1 diff --git a/tests/test-c32stombs-2.sh b/tests/test-c32stombs-2.sh new file mode 100755 index 0000000..573a92f --- /dev/null +++ b/tests/test-c32stombs-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-c32stombs${EXEEXT} 2 diff --git a/tests/test-c32stombs-3.sh b/tests/test-c32stombs-3.sh new file mode 100755 index 0000000..c3c91e7 --- /dev/null +++ b/tests/test-c32stombs-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: ${LOCALE_JA=ja_JP} +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-c32stombs${EXEEXT} 3 diff --git a/tests/test-c32stombs-4.sh b/tests/test-c32stombs-4.sh new file mode 100755 index 0000000..ae3b130 --- /dev/null +++ b/tests/test-c32stombs-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: ${LOCALE_ZH_CN=zh_CN.GB18030} +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-c32stombs${EXEEXT} 4 diff --git a/tests/test-c32stombs.c b/tests/test-c32stombs.c new file mode 100644 index 0000000..ebf542c --- /dev/null +++ b/tests/test-c32stombs.c @@ -0,0 +1,177 @@ +/* Test of conversion of 32-bit wide string to string. + Copyright (C) 2008-2020 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