diff options
-rw-r--r-- | localedata/ChangeLog | 27 | ||||
-rw-r--r-- | localedata/Makefile | 36 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_mbrtowc.c | 140 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_mbsrtowcs.c | 137 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_mbstowcs.c | 129 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_wcrtomb.c | 93 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_wcsrtombs.c | 207 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_wcstod.c | 74 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_wcstok.c | 134 | ||||
-rw-r--r-- | localedata/tests-mbwc/dat_wcstombs.c | 206 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_mbrtowc.c | 103 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_mbsrtowcs.c | 108 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_mbstowcs.c | 97 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_wcrtomb.c | 79 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_wcsrtombs.c | 127 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_wcstod.c | 68 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_wcstok.c | 94 | ||||
-rw-r--r-- | localedata/tests-mbwc/tst_wcstombs.c | 115 |
18 files changed, 1962 insertions, 12 deletions
diff --git a/localedata/ChangeLog b/localedata/ChangeLog index e7bfaf4d24..20ffbfeeeb 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -6,6 +6,15 @@ (tst_strcoll-ENV): New. (tst_strxfrm-ENV): New. (tst_wctomb-ENV): New. + (tst_mbrtowc-ENV): New. + (tst_mbsrtowcs-ENV): New. + (tst_mbstowcs-ENV): New. + (tst_strfmon-ENV): New. + (tst_wcrtomb-ENV): New. + (tst_wcsrtombs-ENV): New. + (tst_wcstod-ENV): New. + (tst_wcstok-ENV): New. + (tst_wcstombs-ENV): New. * tests-mbwc/tst_wctomb.c: New test file from Shoji Kuwabara <kuwahara@cthulhu.engr.sgi.com>. @@ -18,6 +27,24 @@ * tests-mbwc/tst_strcoll.c: Likewise. * tests-mbwc/tst_mblen.c: Likewise. * tests-mbwc/dat_mblen.c: Likewise. + * tests-mbwc/dat_wcstok.c: Likewise. + * tests-mbwc/tst_wcstok.c: Likewise. + * tests-mbwc/dat_wcstod.c: Likewise. + * tests-mbwc/tst_wcstod.c: Likewise. + * tests-mbwc/dat_mbrtowc.c: Likewise. + * tests-mbwc/tst_mbrtowc.c: Likewise. + * tests-mbwc/dat_wcsrtombs.c: Likewise. + * tests-mbwc/tst_wcsrtombs.c: Likewise. + * tests-mbwc/dat_wcstombs.c: Likewise. + * tests-mbwc/tst_wcstombs.c: Likewise. + * tests-mbwc/dat_mbsrtowcs.c: Likewise. + * tests-mbwc/tst_mbsrtowcs.c: Likewise. + * tests-mbwc/dat_wcrtomb.c: Likewise. + * tests-mbwc/tst_wcrtomb.c: Likewise. + * tests-mbwc/dat_mbstowcs.c: Likewise. + * tests-mbwc/tst_mbstowcs.c: Likewise. + * tests-mbwc/dat_strfmon.c: Likewise. + * tests-mbwc/tst_strfmon.c: Likewise. 2000-06-28 Ulrich Drepper <drepper@redhat.com> diff --git a/localedata/Makefile b/localedata/Makefile index fe6ea109c7..97126bfd40 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -76,17 +76,20 @@ include ../Makeconfig ifeq (no,$(cross-compiling)) ifeq (yes,$(build-shared)) -locale_test_suite := tst_iswalnum tst_iswprint tst_towctrans tst_wcsncmp \ - tst_wctrans tst_iswalpha tst_iswpunct tst_wcschr \ - tst_wcspbrk tst_wctype tst_iswcntrl tst_iswspace \ - tst_wcscoll tst_wcsspn tst_iswdigit tst_iswupper \ - tst_wcscpy tst_wcsstr tst_iswgraph tst_iswxdigit \ - tst_wcscspn tst_wcswidth tst_iswlower tst_swscanf \ - tst_wcslen tst_wctob tst_iswctype tst_towlower \ - tst_wcscat tst_towupper tst_wcscmp tst_wcsncat \ - tst_wcsncpy tst_wcsxfrm tst_wcwidth tst_mbrlen \ - tst_mblen tst_strcoll tst_strxfrm tst_mbtowc \ - tst_wctomb +locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \ + tst_iswctype tst_iswdigit tst_iswgraph \ + tst_iswlower tst_iswprint tst_iswpunct \ + tst_iswspace tst_iswupper tst_iswxdigit tst_mblen \ + tst_mbrlen tst_mbrtowc tst_mbsrtowcs tst_mbstowcs \ + tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm \ + tst_swscanf tst_towctrans tst_towlower \ + tst_towupper tst_wcrtomb tst_wcscat tst_wcschr \ + tst_wcscmp tst_wcscoll tst_wcscpy tst_wcscspn \ + tst_wcslen tst_wcsncat tst_wcsncmp tst_wcsncpy \ + tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr \ + tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth \ + tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \ + tst_wctype tst_wcwidth tests = $(locale_test_suite) endif @@ -135,7 +138,7 @@ do-tst-mbswcs: tst-mbswcs.sh $(objpfx)tst-mbswcs1 $(objpfx)tst-mbswcs2 \ do-tst-ctype: tst-ctype.sh $(objpfx)tst-ctype do-collate-test do-tst-mbswcs $(SHELL) -e $< $(common-objpfx) $(addsuffix .out,$(addprefix $(objpfx),$(locale_test_suite))): %: do-tst-ctype\ - do-tst-mbswcs + do-tst-mbswcs endif endif @@ -167,13 +170,18 @@ tst_iswupper-ENV = $(TEST_MBWC_ENV) tst_iswxdigit-ENV = $(TEST_MBWC_ENV) tst_mblen-ENV = $(TEST_MBWC_ENV) tst_mbrlen-ENV = $(TEST_MBWC_ENV) +tst_mbrtowc-ENV = $(TEST_MBWC_ENV) +tst_mbsrtowcs-ENV = $(TEST_MBWC_ENV) +tst_mbstowcs-ENV = $(TEST_MBWC_ENV) tst_mbtowc-ENV = $(TEST_MBWC_ENV) tst_strcoll-ENV = $(TEST_MBWC_ENV) +tst_strfmon-ENV = $(TEST_MBWC_ENV) tst_strxfrm-ENV = $(TEST_MBWC_ENV) tst_swscanf-ENV = $(TEST_MBWC_ENV) tst_towctrans-ENV = $(TEST_MBWC_ENV) tst_towlower-ENV = $(TEST_MBWC_ENV) tst_towupper-ENV = $(TEST_MBWC_ENV) +tst_wcrtomb-ENV = $(TEST_MBWC_ENV) tst_wcscat-ENV = $(TEST_MBWC_ENV) tst_wcschr-ENV = $(TEST_MBWC_ENV) tst_wcscmp-ENV = $(TEST_MBWC_ENV) @@ -185,8 +193,12 @@ tst_wcsncat-ENV = $(TEST_MBWC_ENV) tst_wcsncmp-ENV = $(TEST_MBWC_ENV) tst_wcsncpy-ENV = $(TEST_MBWC_ENV) tst_wcspbrk-ENV = $(TEST_MBWC_ENV) +tst_wcsrtombs-ENV = $(TEST_MBWC_ENV) tst_wcsspn-ENV = $(TEST_MBWC_ENV) tst_wcsstr-ENV = $(TEST_MBWC_ENV) +tst_wcstod-ENV = $(TEST_MBWC_ENV) +tst_wcstok-ENV = $(TEST_MBWC_ENV) +tst_wcstombs-ENV = $(TEST_MBWC_ENV) tst_wcswidth-ENV = $(TEST_MBWC_ENV) tst_wcsxfrm-ENV = $(TEST_MBWC_ENV) tst_wctob-ENV = $(TEST_MBWC_ENV) diff --git a/localedata/tests-mbwc/dat_mbrtowc.c b/localedata/tests-mbwc/dat_mbrtowc.c new file mode 100644 index 0000000000..e8794820b6 --- /dev/null +++ b/localedata/tests-mbwc/dat_mbrtowc.c @@ -0,0 +1,140 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY + * + * FILE: dat_mbrtowc.c + * + * MBTOWC: size_t mbrtowc (wchar_t *pwc, char *s, size_t n, + * mbstate_t *ps); + */ + +#include <limits.h> + +/* Note: + assumes en_US = en_US.ascii +*/ + + + + +TST_MBRTOWC tst_mbrtowc_loc [] = { + { + { Tmbrtowc, TST_LOC_de }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, 1, "ÄÖÜ", 1, 0, 0 }, + { 1, 1, "ÄÖÜ", 2, 0, 0 }, + { 1, 1, "ÄÖÜ", USE_MBCURMAX, 0, 0 }, + } + }, + { + { + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, 1, "ÄÖÜ", 1, 0, 0 }, + { 1, 1, "ÄÖÜ", 2, 0, 0 }, + { 1, 1, "ÄÖÜ", USE_MBCURMAX, 0, 0 }, + } + }, + { + { + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + } + } + }, + { is_last: 1 } + } + }, +#if 0 + /* XXX: These tests don't make sense to me. */ + { + { Tmbrtowc, TST_LOC_enUS }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, 1, "ÄÖÜ", 1, 0, 0 }, + { 1, 1, "ÄÖÜ", 2, 0, 0 }, + { 1, 1, "ÄÖÜ", USE_MBCURMAX, 0, 0 }, + } + }, + { + { + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, 1, "ÄÖÜ", 1, 0, 0 }, + { 1, 1, "ÄÖÜ", 2, 0, 0 }, + { 1, 1, "ÄÖÜ", USE_MBCURMAX, 0, 0 }, + } + }, + { + { + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + } + } + }, + { is_last: 1 } + } + }, + { + { Tmbrtowc, TST_LOC_eucJP }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, 1, "ÄÖÜ", 1, 0, 0 }, + { 1, 1, "ÄÖÜ", 2, 0, 0 }, + { 1, 1, "ÄÖÜ", USE_MBCURMAX, 0, 0 }, + } + }, + { + { + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, 1, "ÄÖÜ", 1, 0, 0 }, + { 1, 1, "ÄÖÜ", 2, 0, 0 }, + { 1, 1, "ÄÖÜ", USE_MBCURMAX, 0, 0 }, + } + }, + { + { + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + { 0, 0, 1, 1, 0x00C4 }, + } + } + }, + { is_last: 1 } + } + }, +#endif + { + { Tmbrtowc, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_mbsrtowcs.c b/localedata/tests-mbwc/dat_mbsrtowcs.c new file mode 100644 index 0000000000..eddc0607b7 --- /dev/null +++ b/localedata/tests-mbwc/dat_mbsrtowcs.c @@ -0,0 +1,137 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY + * + * FILE: dat_mbsrtowcs.c + * + * MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, char **s, size_t n, + * mbstate_t *ps); + */ + + +TST_MBSRTOWCS tst_mbsrtowcs_loc [] = { + { + { Tmbsrtowcs, TST_LOC_de }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, "üäö", 4, 0,0 }, + { 1, "üäö", 3, 0,0 }, + { 1, "üäö", 2, 0,0 }, + } + }, + { + { + { 0,0,1,3, { 0x00FC,0x00E4,0x00F6,0x0000 } }, + { 0,0,1,3, { 0x00FC,0x00E4,0x00F6,0x0000 } }, + { 0,0,1,2, { 0x00FC,0x00E4,0x00F6,0x0000 } }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, "üäö", 4, 0,0 }, + { 1, "", 1, 0,0 }, + { 0, "üäö", 4, 0,0 }, + } + }, + { + { + { 0,0,1,3, { 0x00FC,0x00E4,0x00F6,0x0000 } }, + { 0,0,1,0, { 0x0000 } }, + { 0,0,1,3, { 0x0000 } }, + } + } + }, + { /*----------------- END -----------------*/ + is_last: 1 + } + } + }, + + { + { Tmbsrtowcs, TST_LOC_enUS }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, "ABC", 4, 0,0 }, + { 1, "ABC", 3, 0,0 }, + { 1, "ABC", 2, 0,0 }, + } + }, + { + { + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,2, { 0x0041,0x0042,0x0043,0x0000 } }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, "ABC", 4, 0,0 }, + { 1, "", 1, 0,0 }, + { 0, "ABC", 4, 0,0 }, + } + }, + { + { + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,0, { 0x0000 } }, + { 0,0,1,3, { 0x0000 } }, + } + } + }, + { /*----------------- END -----------------*/ + is_last: 1 + } + } + }, + + { + { Tmbsrtowcs, TST_LOC_eucJP }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, "\244\242\244\244\244\246ABC", 7, 0,0 }, + { 1, "\244\242\244\244\244\246ABC", 6, 0,0 }, + { 1, "\244\242\244\244\244\246ABC", 4, 0,0 }, + } + }, + { + { + { 0,0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }}, + { 0,0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }}, + { 0,0,1,4, { 0x3042,0x3044,0x3046,0x0041,0x0000 } }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, "\244\242\244\244\244\246ABC", 7, 0,0 }, + { 1, "", 1, 0,0 }, + { 0, "\244\242\244\244\244\246ABC", 7, 0,0 }, + } + }, + { + { + { 0,0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }}, + { 0,0,1,0, { 0x0000 } }, + { 0,0,1,6, { 0x0000 } }, + } + } + }, + { /*----------------- END -----------------*/ + is_last: 1 + } + } + }, + { + { Tmbsrtowcs, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_mbstowcs.c b/localedata/tests-mbwc/dat_mbstowcs.c new file mode 100644 index 0000000000..67a621682b --- /dev/null +++ b/localedata/tests-mbwc/dat_mbstowcs.c @@ -0,0 +1,129 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY + * + * FILE: dat_mbstowcs.c + * + * MBSTOWCS: size_t mbstowcs (wchar_t *ws, char *s, size_t n); + */ + +#include <limits.h> + +TST_MBSTOWCS tst_mbstowcs_loc [] = { + { + { Tmbstowcs, TST_LOC_de }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, 1, "ABC", 4 }, + { 1, 1, "ABC", 3 }, + { 1, 1, "ABC", 2 }, + } + }, + { + { + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,2, { 0x0041,0x0042,0x0043,0x0000 } }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, 1, "ABC", 4 }, + { 1, 1, "", 1 }, + { 0, 1, "ABC", 4 }, + } + }, + { + { + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,0, { 0x0000 } }, + { 0,0,1,3, { 0x0000 } }, + } + } + }, + { is_last: 1 } + } + }, + { + { Tmbstowcs, TST_LOC_enUS }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, 1, "ABC", 4 }, + { 1, 1, "ABC", 3 }, + { 1, 1, "ABC", 2 }, + } + }, + { + { + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,2, { 0x0041,0x0042,0x0043,0x0000 } }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, 1, "ABC", 4 }, + { 1, 1, "", 1 }, + { 0, 1, "ABC", 4 }, + } + }, + { + { + { 0,0,1,3, { 0x0041,0x0042,0x0043,0x0000 } }, + { 0,0,1,0, { 0x0000 } }, + { 0,0,1,3, { 0x0000 } }, + } + } + }, + { is_last: 1 } + } + }, + { + { Tmbstowcs, TST_LOC_eucJP }, + { + { /*----------------- #01 -----------------*/ + { + { + { 1, 1, "\244\242\244\244\244\246ABC", 7 }, + { 1, 1, "\244\242\244\244\244\246ABC", 6 }, + { 1, 1, "\244\242\244\244\244\246ABC", 4 }, + } + }, + { + { + { 0,0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }}, + { 0,0,1,6, { 0x3042,0x3044,0x3046,0x0041,0x0042,0x0043,0x0000 }}, + { 0,0,1,4, { 0x3042,0x3044,0x3046,0x0041,0x0000 } }, + } + } + }, + { /*----------------- #02 -----------------*/ + { + { + { 1, 1, "\244\242\244\244\244\246ABC", 7 }, + { 1, 1, "", 1 }, + { 0, 1, "\244\242\244\244\244\246ABC", 7 }, + } + }, + { + { + { 0,0,1,4, { 0x3042,0x3044,0x3046,0x0041,0x0000 } }, + { 0,0,1,0, { 0x0000 } }, + { 0,0,1,6, { 0x0000 } }, + } + } + }, + { is_last: 1 } + } + }, + { + { Tmbstowcs, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_wcrtomb.c b/localedata/tests-mbwc/dat_wcrtomb.c new file mode 100644 index 0000000000..529232396f --- /dev/null +++ b/localedata/tests-mbwc/dat_wcrtomb.c @@ -0,0 +1,93 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY + * + * FILE: dat_wcrtomb.c + * + * WCRTOMB: intwcrtomb (char *s, wchar_t wc, mbstate_t *ps); + * + */ + +TST_WCRTOMB tst_wcrtomb_loc [] = { + { + { Twcrtomb, TST_LOC_de }, + { + /* #01 : normal case */ + { /*input.*/ { 1, 0x00FC, 0,0 }, + /*expect*/ { 1,0, 1,1, "ü" }, + }, + /* #02 : normal case */ + { /*input.*/ { 1, 0x00D6, 0,0 }, + /*expect*/ { 1,0, 1,1, "Ö" }, + }, + /* #03 : error case */ + { /*input.*/ { 1, 0xFFA1, 0,0 }, + /*expect*/ { 1, EILSEQ,1,-1, "" }, + }, + /* #04 : */ + { /*input.*/ { 0, 0x0041, 0,0 }, + /*expect*/ { 1,0, 1,1, "" }, + }, + /* #05 : */ + { /*input.*/ { 0, 0x0092, 0,0 }, + /*expect*/ { 1,0, 1,1, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcrtomb, TST_LOC_enUS }, + { + /* #01 : normal case */ + { /*input.*/ { 1, 0x0041, 0,0 }, + /*expect*/ { 0,0, 1,1, "A" }, + }, + /* #02 : normal case */ + { /*input.*/ { 1, 0x0042, 0,0 }, + /*expect*/ { 0,0, 1,1, "B" }, + }, + /* #03 : error case */ + /* <WAIVER> x 2 */ + { /*input.*/ { 1, 0x0092, 0,0 }, /* assume ascii */ + /*expect*/ { 1, EILSEQ,1,-1, "" }, + }, + /* #04 : */ + { /*input.*/ { 0, 0x0041, 0,0 }, + /*expect*/ { 1,0, 1,1, "" }, + }, + /* #05 : */ + { /*input.*/ { 0, 0x0092, 0,0 }, + /*expect*/ { 1,0, 1,1, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcrtomb, TST_LOC_eucJP }, + { + /* #01 : normal case */ + { /*input.*/ { 1, 0x3042, 0,0 }, + /*expect*/ { 0,0, 1,2, "\244\242" }, + }, + /* #02 : normal case */ + { /*input.*/ { 1, 0x3044, 0,0 }, + /*expect*/ { 0,0, 1,2, "\244\244" }, + }, + /* #03 : normal case */ + { /*input.*/ { 1, 0x008E, 0,0 }, + /*expect*/ { 1,EILSEQ, 1,-1, "" }, + }, + /* #04 : */ + { /*input.*/ { 0, 0x3042, 0,0 }, + /*expect*/ { 1,0, 0,0, "" }, + }, + /* #05 : */ + { /*input.*/ { 0, 0x008E, 0,0 }, + /*expect*/ { 1,0, 0,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcrtomb, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_wcsrtombs.c b/localedata/tests-mbwc/dat_wcsrtombs.c new file mode 100644 index 0000000000..181cfff4e0 --- /dev/null +++ b/localedata/tests-mbwc/dat_wcsrtombs.c @@ -0,0 +1,207 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY + * + * FILE: dat_wcsrtombs.c + * + * WCSTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, + * size_t n, mbstate *ps) + */ + + +/* + * CAUTION: + * Do not use a value 0x01 for string data. The test program + * uses it. + * + */ + + +TST_WCSRTOMBS tst_wcsrtombs_loc [] = { + { + { Twcsrtombs, TST_LOC_de }, + { + /* #01 : Any chars including a null char should not be stored in s. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0}, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #02 : Only one chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 }, + /*expect*/ { 1,0,1,1, "Ä" }, + }, + /* #03 : Only two chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 2, 0, 0 }, + /*expect*/ { 1,0,1,2, "ÄÖ" }, + }, + /* #04 : Only three chars should be stored in s. No null + termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 3, 0, 0 }, + /*expect*/ { 1,0,1,3, "ÄÖÜ" }, + }, + /* #05 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 4, 0, 0 }, + /*expect*/ { 1,0,1,3, "ÄÖÜ" }, + }, + /* #06 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,3, "ÄÖÜ" }, + }, + /* #07 : Invalid mb sequence. No chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #08 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #09 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #10 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #11 : s is a null pointer. No chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #12 : ws is a null wc string, no chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #13 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcsrtombs, TST_LOC_enUS }, + { + /* #01 : Any chars including a null char should not be stored in s. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #02 : Only one chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 }, + /*expect*/ { 1,0,1,1, "A" }, + }, + /* #03 : Only two chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 2, 0, 0 }, + /*expect*/ { 1,0,1,2, "AB" }, + }, + /* #04 : Only three chars should be stored in s. No null + termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 3, 0, 0 }, + /*expect*/ { 1,0,1,3, "ABC" }, + }, + /* #05 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 4, 0, 0 }, + /*expect*/ { 1,0,1,3, "ABC" }, + }, + /* #06 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,3, "ABC" }, + }, + /* #07 : Invalid mb sequence. No chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #08 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #09 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #10 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #11 : s is a null pointer. No chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #12 : ws is a null wc string, no chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #13 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcsrtombs, TST_LOC_eucJP }, + { + + /* #01 : Any chars including a null char should not be stored in s. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #02 : Only one chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 2, 0, 0 }, + /*expect*/ { 1,0,1,2, "\244\242" }, + }, + /* #03 : Only two chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 4, 0, 0 }, + /*expect*/ { 1,0,1,4, "\244\242\244\244" }, + }, + /* #04 : Only three chars should be stored in s. No null + termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 6, 0, 0 }, + /*expect*/ { 1,0,1,6, "\244\242\244\244\216\263" }, + }, + /* #05 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 7, 0, 0 }, + /*expect*/ { 1,0,1,6, "\244\242\244\244\216\263" }, + }, + /* #06 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 }, + /*expect*/ { 1,0,1,6, "\244\242\244\244\216\263" }, + }, + /* #07 : Invalid mb sequence. No chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 }, + /*expect*/ { 1,EILSEQ,1,-1, "" }, + }, + /* #08 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0, 0, 0 }, + /*expect*/ { 1,0,1,6, "" }, + }, + /* #09 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 1, 0, 0 }, + /*expect*/ { 1,0,1,6, "" }, + }, + /* #10 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 }, + /*expect*/ { 1,0,1,6, "" }, + }, + /* #11 : s is a null pointer. No chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #12 : ws is a null wc string, no chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #13 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0000 }, 5, 0, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcsrtombs, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_wcstod.c b/localedata/tests-mbwc/dat_wcstod.c new file mode 100644 index 0000000000..f677603de6 --- /dev/null +++ b/localedata/tests-mbwc/dat_wcstod.c @@ -0,0 +1,74 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY + * + * FILE: dat_wcstod.c + * + * WCSTOD: double wcstod (const wchar_t *np, wchar_t **endp); + */ + + +/* + * NOTE: + * need more test data! + * + */ + + +TST_WCSTOD tst_wcstod_loc [] = { + { + { Twcstod, TST_LOC_de }, + { + { + /*01*/ + /*I*/ + {{ 0x0030,0x0030,0x0030,0x002C,0x0030,0x0030,0x0030,0x0030,0x0000 }}, + /*E*/ + { 0,0,1,0.0, 0.0, 0x0000 } + }, + { + /*02*/ + /*I*/ + {{ 0x0031,0x0032,0x0033,0x002C,0x0034,0x0035,0x0036,0x0040,0x0000 }}, + /*E*/ + { 0,0,1,123.456, 123.456, 0x0040 } + }, + { is_last: 1 } + } + }, + { + { Twcstod, TST_LOC_enUS }, + { + { + /*01*/ + /*I*/ + {{ 0x0030,0x0030,0x0030,0x002E,0x0030,0x0030,0x0030,0x0030,0x0000 }}, + /*E*/ + { 0,0,1,0.0, 0.0, 0x0000 } + }, + { + /*02*/ + /*I*/ + {{ 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0040,0x0000 }}, + /*E*/ + { 0,0,1,123.456, 123.456, 0x0040 } + }, + { is_last: 1 } + } + }, + { + { Twcstod, TST_LOC_eucJP }, + { + { + /*01*/ + /*I*/ + {{ 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0040,0x0000 }}, + /*E*/ + { 0,0,1,123.456, 123.456, 0x0040 } + }, + { is_last: 1 } + } + }, + { + { Twcstod, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_wcstok.c b/localedata/tests-mbwc/dat_wcstok.c new file mode 100644 index 0000000000..8c6dfb0897 --- /dev/null +++ b/localedata/tests-mbwc/dat_wcstok.c @@ -0,0 +1,134 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY + * + * FILE: dat_wcstok.c + * + * WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, + * wchar_t **pt); + */ + +/* + * NOTE: + * need more test data! + * locale insensitive function... + */ + + + + +TST_WCSTOK tst_wcstok_loc [] = { + { + { Twcstok, TST_LOC_de }, + { + { + { + { + { 1, { 0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,0x00D8, + 0x00D9,0x0000 }, + { 0x00D3,0x00D2, 0x00D5 } + }, + { 0, { 0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,0x00D8, + 0x00D9,0x0000 }, + { 0x00D3,0x00D2, 0x00D5 } + }, + { 0, { 0x00D1,0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D7,0x00D8, + 0x00D9,0x0000 }, + { 0x00D3,0x00D2, 0x00D5 } + }, + } + }, + { + { + { 0,0, 0,0, + { 0x00D1,0x0000 } + }, + { 0,0, 0,0, + { 0x00D4,0x0000 } + }, + { 0,0, 0,0, + { 0x00D6,0x00D7,0x00D8,0x00D9,0x0000 } + }, + } + } + }, + { is_last: 1 } + } + }, + { + { Twcstok, TST_LOC_enUS }, + { + { + { + { + { 1, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, + 0x0049,0x0000 }, + { 0x0043,0x0042, 0x0045 } + }, + { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, + 0x0049,0x0000 }, + { 0x0043,0x0042, 0x0045 } + }, + { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, + 0x0049,0x0000 }, + { 0x0043,0x0042, 0x0045 } + }, + } + }, + { + { + { 0,0, 0,0, + { 0x0041,0x0000 } + }, + { 0,0, 0,0, + { 0x0044,0x0000 } + }, + { 0,0, 0,0, + { 0x0046,0x0047,0x0048,0x0049,0x0000 } + }, + } + } + }, + { is_last: 1 } + } + }, + { + { Twcstok, TST_LOC_eucJP }, + { + { + { + { + { 1, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, + 0x0049,0x0000 }, + { 0x0043,0x0042, 0x0045 } + }, + { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, + 0x0049,0x0000 }, + { 0x0043,0x0042, 0x0045 } + }, + { 0, { 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, + 0x0049,0x0000 }, + { 0x0043,0x0042, 0x0045 } + }, + } + }, + { + { + { 0,0, 0,0, + { 0x0041,0x0000 } + }, + { 0,0, 0,0, + { 0x0044,0x0000 } + }, + { 0,0, 0,0, + { 0x0046,0x0047,0x0048,0x0049,0x0000 } + }, + } + } + }, + { is_last: 1 } + } + }, + { + { Twcstok, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/dat_wcstombs.c b/localedata/tests-mbwc/dat_wcstombs.c new file mode 100644 index 0000000000..0f136b0897 --- /dev/null +++ b/localedata/tests-mbwc/dat_wcstombs.c @@ -0,0 +1,206 @@ +/* + * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY + * + * FILE: dat_wcstombs.c + * + * WCSTOMBS: size_t wcstombs (char *s, const wchar_t *ws, size_t n) + */ + + +/* + * CAUTION: + * Do not use a value 0x01 for string data. The test program + * uses it. + * + */ + + +TST_WCSTOMBS tst_wcstombs_loc [] = { + { + { Twcstombs, TST_LOC_de }, + { + /* #01 : Any chars including a null char should not be stored in s. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #02 : Only one chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 }, + /*expect*/ { 1,0,1,1, "Ä" }, + }, + /* #03 : Only two chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 2 }, + /*expect*/ { 1,0,1,2, "ÄÖ" }, + }, + /* #04 : Only three chars should be stored in s. No null + termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 3 }, + /*expect*/ { 1,0,1,3, "ÄÖÜ" }, + }, + /* #05 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 4 }, + /*expect*/ { 1,0,1,3, "ÄÖÜ" }, + }, + /* #06 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 }, + /*expect*/ { 1,0,1,3, "ÄÖÜ" }, + }, + /* #07 : Invalid mb sequence. No chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #08 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #09 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #10 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #11 : s is a null pointer. No chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #12 : ws is a null wc string, no chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0000 }, 5 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #13 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0000 }, 5 }, + /*expect*/ { 1,0,1,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcstombs, TST_LOC_enUS }, + { + /* #01 : Any chars including a null char should not be stored in s. */ + { /*input.*/ { 1,1, { 0x00C4,0x0042,0x0043,0x0000 }, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #02 : Only one chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 1 }, + /*expect*/ { 1,0,1,1, "A" }, + }, + /* #03 : Only two chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 2 }, + /*expect*/ { 1,0,1,2, "AB" }, + }, + /* #04 : Only three chars should be stored in s. No null + termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 3 }, + /*expect*/ { 1,0,1,3, "ABC" }, + }, + /* #05 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 4 }, + /*expect*/ { 1,0,1,3, "ABC" }, + }, + /* #06 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x0041,0x0042,0x0043,0x0000 }, 5 }, + /*expect*/ { 1,0,1,3, "ABC" }, + }, + /* #07 : Invalid mb sequence. No chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #08 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 0 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #09 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 1 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #10 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0041,0x0042,0x0043,0x0000 }, 5 }, + /*expect*/ { 1,0,1,3, "" }, + }, + /* #11 : s is a null pointer. No chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #12 : ws is a null wc string, no chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0000 }, 5, }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #13 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0000 }, 5 }, + /*expect*/ { 1,0,1,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcstombs, TST_LOC_eucJP }, + { + + /* #01 : Any chars including a null char should not be stored in s. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #02 : Only one chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 2 }, + /*expect*/ { 1,0,1,2, "\244\242" }, + }, + /* #03 : Only two chars should be stored in s. No null termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 4 }, + /*expect*/ { 1,0,1,4, "\244\242\244\244" }, + }, + /* #04 : Only three chars should be stored in s. No null + termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 6 }, + /*expect*/ { 1,0,1,6, "\244\242\244\244\216\263" }, + }, + /* #05 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 7 }, + /*expect*/ { 1,0,1,6, "\244\242\244\244\216\263" }, + }, + /* #06 : Only three chars should be stored in s with a null + termination. */ + { /*input.*/ { 1,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 }, + /*expect*/ { 1,0,1,6, "\244\242\244\244\216\263" }, + }, + /* #07 : Invalid mb sequence. No chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0201,0x0221,0x0000,0x0000 }, 2 }, + /*expect*/ { 1,EILSEQ,1,-1, "" }, + }, + /* #08 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 0 }, + /*expect*/ { 1,0,1,6, "" }, + }, + /* #09 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 1 }, + /*expect*/ { 1,0,1,6, "" }, + }, + /* #10 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x3042,0x3044,0xFF73,0x0000 }, 8 }, + /*expect*/ { 1,0,1,6, "" }, + }, + /* #11 : s is a null pointer. No chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0201,0x0221,0x0000,0x0000 }, 5 }, + /*expect*/ { 1,EILSEQ,1,(size_t)-1, "" }, + }, + /* #12 : ws is a null wc string, no chars should be stored in s. */ + { /*input.*/ { 1,1, { 0x0000 }, 5 }, + /*expect*/ { 1,0,1,0, "" }, + }, + /* #13 : s is a null pointer, no chars should be stored in s. */ + { /*input.*/ { 0,1, { 0x0000 }, 5 }, + /*expect*/ { 1,0,1,0, "" }, + }, + { is_last: 1 } + } + }, + { + { Twcstombs, TST_LOC_end } + } +}; diff --git a/localedata/tests-mbwc/tst_mbrtowc.c b/localedata/tests-mbwc/tst_mbrtowc.c new file mode 100644 index 0000000000..8b8c07f947 --- /dev/null +++ b/localedata/tests-mbwc/tst_mbrtowc.c @@ -0,0 +1,103 @@ +/* + MBRTOWC: size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, + mbstate_t *ps) +*/ + +#define TST_FUNCTION mbrtowc + +#include "tsp_common.c" +#include "dat_mbrtowc.c" + + +int +tst_mbrtowc (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (size_t); + char w_flg, s_flg; + char *s; + size_t n; + char t_flg, t_ini; + static mbstate_t t = { 0 }; + mbstate_t *pt; + wchar_t wc, *pwc, wc_ex; + + TST_DO_TEST (mbrtowc) + { + TST_HEAD_LOCALE (mbrtowc, S_MBRTOWC); + TST_DO_REC (mbrtowc) + { + if (mbrtowc (NULL, "", 0, &t) != 0) + { + err_count++; + Result (C_FAILURE, S_MBRTOWC, CASE_3, + "Initialization failed - skipping this test case."); + continue; + } + + TST_DO_SEQ (MBRTOWC_SEQNUM) + { + TST_GET_ERRET_SEQ (mbrtowc); + w_flg = TST_INPUT_SEQ (mbrtowc).w_flg; + s_flg = TST_INPUT_SEQ (mbrtowc).s_flg; + s = TST_INPUT_SEQ (mbrtowc).s; + n = TST_INPUT_SEQ (mbrtowc).n; + t_flg = TST_INPUT_SEQ (mbrtowc).t_flg; + t_ini = TST_INPUT_SEQ (mbrtowc).t_init; + pwc = (w_flg == 0) ? NULL : &wc; + + if (s_flg == 0) + { + s = NULL; + } + + if (n == USE_MBCURMAX) + { + n = MB_CUR_MAX; + } + + pt = (t_flg == 0) ? NULL : &t; +#if 0 + if (t_ini != 0) + { + memset (&t, 0, sizeof (t)); + } +#endif + TST_CLEAR_ERRNO; + ret = mbrtowc (pwc, s, n, pt); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stdout, "mbrtowc() [ %s : %d : %d ] ret = %d\n", + locale, rec + 1, seq_num + 1, ret); + fprintf (stdout, " errno = %hd\n", + errno_save); + } + + TST_IF_RETURN (S_MBRTOWC) + { + }; + + if (pwc == NULL || s == NULL || ret == (size_t) - 1 + || ret == (size_t) - 2) + { + continue; + } + + wc_ex = TST_EXPECT_SEQ (mbrtowc).wc; + if (wc_ex == wc) + { + Result (C_SUCCESS, S_MBRTOWC, CASE_4, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_MBRTOWC, CASE_4, + "converted wc is different from an expected wc"); + } + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_mbsrtowcs.c b/localedata/tests-mbwc/tst_mbsrtowcs.c new file mode 100644 index 0000000000..f9faeee196 --- /dev/null +++ b/localedata/tests-mbwc/tst_mbsrtowcs.c @@ -0,0 +1,108 @@ +/* + MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, const char **s, size_t n, + mbstate_t *ps) +*/ + +#define TST_FUNCTION mbsrtowcs + +#include "tsp_common.c" +#include "dat_mbsrtowcs.c" + +int +tst_mbsrtowcs (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (size_t); + char w_flg; + const char *s, *p; + size_t n; + char t_flg, t_ini; + static mbstate_t t = { 0 }; + mbstate_t *pt; + wchar_t ws[WCSSIZE], *ws_ex, *wp; + int err, i; + + TST_DO_TEST (mbsrtowcs) + { + TST_HEAD_LOCALE (mbsrtowcs, S_MBSRTOWCS); + TST_DO_REC (mbsrtowcs) + { + s = ""; + if (mbsrtowcs (NULL, &s, 0, &t) != 0) + { + err_count++; + Result (C_FAILURE, S_MBSRTOWCS, CASE_3, + "Initialization failed - skipping this test case."); + continue; + } + + TST_DO_SEQ (MBSRTOWCS_SEQNUM) + { + TST_GET_ERRET_SEQ (mbsrtowcs); + w_flg = TST_INPUT_SEQ (mbsrtowcs).w_flg; + p = s = TST_INPUT_SEQ (mbsrtowcs).s; + n = TST_INPUT_SEQ (mbsrtowcs).n; + t_flg = TST_INPUT_SEQ (mbsrtowcs).t_flg; + t_ini = TST_INPUT_SEQ (mbsrtowcs).t_init; + wp = (w_flg == 0) ? NULL : ws; + + if (n == USE_MBCURMAX) + { + n = MB_CUR_MAX; + } + + pt = (t_flg == 0) ? NULL : &t; + + if (t_ini != 0) + { + memset (&t, 0, sizeof (t)); + } + + TST_CLEAR_ERRNO; + ret = mbsrtowcs (wp, &p, n, pt); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stderr, "mbsrtowcs: [ %d ] : ret = %d\n", rec + 1, ret); + } + + TST_IF_RETURN (S_MBSRTOWCS) + { + }; + + if (wp == NULL || ret == (size_t) - 1 || ret == (size_t) - 2) + { + continue; + } + + ws_ex = TST_EXPECT_SEQ (mbsrtowcs).ws; + for (err = 0, i = 0; i < ret; i++) + { + if (debug_flg) + { + fprintf (stderr, + "mbsrtowcs: ws[%d] => 0x%lx : 0x%lx <= ws_ex[%d]\n", + i, ws[i], ws_ex[i], i); + } + + if (ws[i] != ws_ex[i]) + { + err++; + err_count++; + Result (C_FAILURE, S_MBSRTOWCS, CASE_4, + "the converted wc string has " + "different value from an expected string"); + break; + } + } + + if (!err) + { + Result (C_SUCCESS, S_MBSRTOWCS, CASE_4, MS_PASSED); + } + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_mbstowcs.c b/localedata/tests-mbwc/tst_mbstowcs.c new file mode 100644 index 0000000000..56928bd7dd --- /dev/null +++ b/localedata/tests-mbwc/tst_mbstowcs.c @@ -0,0 +1,97 @@ +/* + MBSTOWCS: size_t mbstowcs (wchar_t *ws, char *s, size_t n) +*/ + +#define TST_FUNCTION mbstowcs + +#include "tsp_common.c" +#include "dat_mbstowcs.c" + +int +tst_mbstowcs (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (size_t); + char w_flg, s_flg; + const char *s; + size_t n; + wchar_t ws[WCSSIZE], *ws_ex, *wp; + int err, i; + + TST_DO_TEST (mbstowcs) + { + TST_HEAD_LOCALE (mbstowcs, S_MBSTOWCS); + TST_DO_REC (mbstowcs) + { + if (mbstowcs (NULL, "", 0) != 0) + { + err_count++; + Result (C_FAILURE, S_MBSTOWCS, CASE_3, + "Initialization failed - skipping this test case."); + continue; + } + + TST_DO_SEQ (MBSTOWCS_SEQNUM) + { + TST_GET_ERRET_SEQ (mbstowcs); + w_flg = TST_INPUT_SEQ (mbstowcs).w_flg; + s_flg = TST_INPUT_SEQ (mbstowcs).s_flg; + n = TST_INPUT_SEQ (mbstowcs).n; + + if (s_flg == 0) + s = NULL; + else + s = TST_INPUT_SEQ (mbstowcs).s; + + + wp = (wchar_t *) ((w_flg == 0) ? NULL : ws); + + TST_CLEAR_ERRNO; + ret = mbstowcs (wp, s, n); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stderr, "mbstowcs: ret = %d\n", ret); + } + + TST_IF_RETURN (S_MBSTOWCS) + { + }; + + if (s == NULL || wp == NULL || ret == (size_t) - 1) + { + continue; + } + + ws_ex = TST_EXPECT_SEQ (mbstowcs).ws; + + for (err = 0, i = 0; i < ret; i++) + { + if (debug_flg) + { + fprintf (stderr, + "mbstowcs: ws[%d] => 0x%lx : 0x%lx <= ws_ex[%d]\n", + i, ws[i], ws_ex[i], i); + } + + if (ws[i] != ws_ex[i]) + { + err++; + err_count++; + Result (C_FAILURE, S_MBSTOWCS, CASE_4, + "the converted wc string has " + "different value from an expected string"); + break; + } + } + + if (!err) + { + Result (C_SUCCESS, S_MBSTOWCS, CASE_4, MS_PASSED); + } + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_wcrtomb.c b/localedata/tests-mbwc/tst_wcrtomb.c new file mode 100644 index 0000000000..0029a49405 --- /dev/null +++ b/localedata/tests-mbwc/tst_wcrtomb.c @@ -0,0 +1,79 @@ +/* + WCRTOMB: wchar_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps) +*/ + +#define TST_FUNCTION wcrtomb + +#include "tsp_common.c" +#include "dat_wcrtomb.c" + + +int +tst_wcrtomb (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (wchar_t); + wchar_t wc; + char s[MBSSIZE], *s_in, *s_ex; + char t_flg, t_ini; + static mbstate_t t = { 0 }; + mbstate_t *pt; + int err, i; + + TST_DO_TEST (wcrtomb) + { + TST_HEAD_LOCALE (wcrtomb, S_WCRTOMB); + TST_DO_REC (wcrtomb) + { + TST_GET_ERRET (wcrtomb); + s_in = ((TST_INPUT (wcrtomb).s_flg) == 0) ? (char *) NULL : s; + wc = TST_INPUT (wcrtomb).wc; + t_flg = TST_INPUT (wcrtomb).t_flg; + t_ini = TST_INPUT (wcrtomb).t_init; + pt = (t_flg == 0) ? NULL : &t; + + if (t_ini != 0) + { + memset (&t, 0, sizeof (t)); + } + + TST_CLEAR_ERRNO; + ret = wcrtomb (s_in, wc, pt); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stdout, "wcrtomb() [ %s : %d ] ret = %lu\n", locale, + rec + 1, (unsigned long int) ret); + fprintf (stdout, " errno = %d\n", errno_save); + } + + TST_IF_RETURN (S_WCRTOMB) + { + }; + + s_ex = TST_EXPECT (wcrtomb).s; + + if (s_in) + { + for (i = 0, err = 0; *(s_ex + i) != 0 && i < MBSSIZE; i++) + { + if (s_in[i] != s_ex[i]) + { + err++; + err_count++; + Result (C_FAILURE, S_WCRTOMB, CASE_4, + "copied string is different from an " + "expected string"); + break; + } + } + if (!err) + { + Result (C_SUCCESS, S_WCRTOMB, CASE_4, MS_PASSED); + } + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_wcsrtombs.c b/localedata/tests-mbwc/tst_wcsrtombs.c new file mode 100644 index 0000000000..02a69a0fcc --- /dev/null +++ b/localedata/tests-mbwc/tst_wcsrtombs.c @@ -0,0 +1,127 @@ +/* + WCSRTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, size_t n, + mbstate_t *ps) +*/ + +#define TST_FUNCTION wcsrtombs + +#include "tsp_common.c" +#include "dat_wcsrtombs.c" + +#define MARK_VAL 0x01 + +int +tst_wcsrtombs (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (size_t); + char s_flg, n; + const wchar_t *ws, *wp; + char s[MBSSIZE], *s_in; + char t_flg, t_ini; + static mbstate_t t = { 0 }; + mbstate_t *pt; + int err, i; + char *s_ex; + + TST_DO_TEST (wcsrtombs) + { + TST_HEAD_LOCALE (wcsrtombs, S_WCSRTOMBS); + TST_DO_REC (wcsrtombs) + { + TST_GET_ERRET (wcsrtombs); + memset (s, MARK_VAL, MBSSIZE); + + s_flg = TST_INPUT (wcsrtombs).s_flg; + s_in = (s_flg == 1) ? s : (char *) NULL; + wp = ws = TST_INPUT (wcsrtombs).ws; + n = TST_INPUT (wcsrtombs).n; + t_flg = TST_INPUT (wcsrtombs).t_flg; + t_ini = TST_INPUT (wcsrtombs).t_init; + pt = (t_flg == 0) ? NULL : &t; + + if (t_ini != 0) + { + memset (&t, 0, sizeof (t)); + } + + TST_CLEAR_ERRNO; + ret = wcsrtombs (s_in, &wp, n, pt); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stderr, "wcsrtombs: ret = %d\n", ret); + } + + TST_IF_RETURN (S_WCSRTOMBS) + { + }; + + if (s_in != NULL && ret != (size_t) - 1) + { + /* No definition for s, when error occurs. */ + s_ex = TST_EXPECT (wcsrtombs).s; + + for (err = 0, i = 0; i <= ret && i < MBSSIZE; i++) + { + if (debug_flg) + { + fprintf (stderr, + " : s[%d] = 0x%hx <-> 0x%hx = s_ex[%d]\n", i, + s[i], s_ex[i], i); + } + + if (i == ret && ret == n) /* no null termination */ + { + if (s[i] == MARK_VAL) + { + Result (C_SUCCESS, S_WCSRTOMBS, CASE_4, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_WCSRTOMBS, CASE_4, + "should not be null terminated " + "(it may be a null char), but it is"); + } + + break; + } + + if (i == ret && ret < n) /* null termination */ + { + if (s[i] == 0) + { + Result (C_SUCCESS, S_WCSRTOMBS, CASE_5, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_WCSRTOMBS, CASE_5, + "should be null terminated, but it is not"); + } + + break; + } + + if (s[i] != s_ex[i]) + { + err++; + err_count++; + Result (C_FAILURE, S_WCSRTOMBS, CASE_6, + "converted string is different from an" + " expected string"); + break; + } + } + + if (!err) + { + Result (C_SUCCESS, S_WCSRTOMBS, CASE_6, MS_PASSED); + } + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_wcstod.c b/localedata/tests-mbwc/tst_wcstod.c new file mode 100644 index 0000000000..5ee151bd54 --- /dev/null +++ b/localedata/tests-mbwc/tst_wcstod.c @@ -0,0 +1,68 @@ +/* + WCSTOD: double wcstod (wchar_t *np, const wchar_t **endp); +*/ + +#define TST_FUNCTION wcstod + +#include "tsp_common.c" +#include "dat_wcstod.c" + +int +tst_wcstod (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (double); + wchar_t *np, *endp, fwc; + double val; + + TST_DO_TEST (wcstod) + { + TST_HEAD_LOCALE (wcstod, S_WCSTOD); + TST_DO_REC (wcstod) + { + TST_GET_ERRET (wcstod); + np = TST_INPUT (wcstod).np; + + TST_CLEAR_ERRNO; + ret = wcstod (np, &endp); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stdout, "wcstod() [ %s : %d ] ret = %f\n", locale, + rec + 1, ret); + fprintf (stdout, " *endp = 0x%lx\n", *endp); + } + + TST_IF_RETURN (S_WCSTOD) + { + if (ret != 0) + { + val = ret - TST_EXPECT (wcstod).val; + if (TST_ABS (val) < TST_DBL_EPS) + { + Result (C_SUCCESS, S_WCSTOD, CASE_3, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_WCSTOD, CASE_3, "return value is wrong"); + } + } + } + + fwc = TST_EXPECT (wcstod).fwc; + + if (fwc == *endp) + { + Result (C_SUCCESS, S_WCSTOD, CASE_4, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_WCSTOD, CASE_4, "a final wc is wrong."); + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_wcstok.c b/localedata/tests-mbwc/tst_wcstok.c new file mode 100644 index 0000000000..3b80a61011 --- /dev/null +++ b/localedata/tests-mbwc/tst_wcstok.c @@ -0,0 +1,94 @@ +/* + WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, wchar_t **pt); +*/ + + +#define TST_FUNCTION wcstok + +#include "tsp_common.c" +#include "dat_wcstok.c" + +int +tst_wcstok (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (wchar_t *); + char w_flg; + wchar_t *ws; + wchar_t *dt, *pt; + wchar_t *ws_ex; + int err, i; + + TST_DO_TEST (wcstok) + { + TST_HEAD_LOCALE (wcstok, S_WCSTOK); + TST_DO_REC (wcstok) + { + TST_DO_SEQ (WCSTOK_SEQNUM) + { + TST_GET_ERRET_SEQ (wcstok); + w_flg = TST_INPUT_SEQ (wcstok).w_flg; + ws = (w_flg) ? TST_INPUT_SEQ (wcstok).ws : NULL; + dt = TST_INPUT_SEQ (wcstok).dt; + + ret = wcstok (ws, dt, &pt); + + if (debug_flg) + { + fprintf (stdout, "wcstok() [ %s : %d : %d ] *ret = 0x%lx\n", + locale, rec + 1, seq_num + 1, *ret); + if (pt && *pt) + { + fprintf (stdout, " *pt = 0x%lx\n", + *pt); + } + } + + TST_IF_RETURN (S_WCSTOK) + { + }; + + if (ret != NULL) + { + ws_ex = TST_EXPECT_SEQ (wcstok).ws; + + /* XXX: REVISIT : insufficient conditions */ + for (err = 0, i = 0; i < WCSSIZE; i++) + { + if (ret[i] == L'\0' && ws_ex[i] == L'\0') + { + break; + } + + if (debug_flg) + { + fprintf (stderr, + " ret[%d] = 0x%lx <-> " + "0x%lx = ws_ex[%d]\n", i, ret[i], ws_ex[i], i); + } + + if (ret[i] != ws_ex[i]) + { + err++; + err_count++; + Result (C_FAILURE, S_WCSTOK, CASE_3, + "the token is different from an expected string"); + break; + } + + if (ret[i] == L'\0' || ws_ex[i] == L'\0') + { + break; + } + } + + if (!err) + { + Result (C_SUCCESS, S_WCSTOK, CASE_3, MS_PASSED); + } + } + } + } + } + + return err_count; +} diff --git a/localedata/tests-mbwc/tst_wcstombs.c b/localedata/tests-mbwc/tst_wcstombs.c new file mode 100644 index 0000000000..64a327dadc --- /dev/null +++ b/localedata/tests-mbwc/tst_wcstombs.c @@ -0,0 +1,115 @@ +/* + WCSTOMBS: size_t wcstombs (char *s, const wchar_t *ws, size_t n) +*/ + +#define TST_FUNCTION wcstombs + +#include "tsp_common.c" +#include "dat_wcstombs.c" + +#define MARK_VAL 0x01 + +int +tst_wcstombs (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (size_t); + char s_flg, n; + wchar_t *ws; + char s[MBSSIZE], *s_in; + int err, i; + char *s_ex; + + TST_DO_TEST (wcstombs) + { + TST_HEAD_LOCALE (wcstombs, S_WCSTOMBS); + TST_DO_REC (wcstombs) + { + TST_GET_ERRET (wcstombs); + memset (s, MARK_VAL, MBSSIZE); + + s_flg = TST_INPUT (wcstombs).s_flg; + s_in = (s_flg == 1) ? s : (char *) NULL; + ws = TST_INPUT (wcstombs).ws; + n = TST_INPUT (wcstombs).n; + + TST_CLEAR_ERRNO; + ret = wcstombs (s_in, ws, n); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stdout, "wcstombs: ret = %d\n", ret); + } + + TST_IF_RETURN (S_WCSTOMBS) + { + }; + + if (s_in != NULL && ret != (size_t) - 1) + { + /* No definition for s, when error occurs. */ + s_ex = TST_EXPECT (wcstombs).s; + + for (err = 0, i = 0; i <= ret && i < MBSSIZE; i++) + { + if (debug_flg) + { + fprintf (stdout, + " : s[%d] = 0x%hx <-> 0x%hx = s_ex[%d]\n", i, + s[i], s_ex[i], i); + } + + if (i == ret && ret == n) /* no null termination */ + { + if (s[i] == MARK_VAL) + { + Result (C_SUCCESS, S_WCSTOMBS, CASE_4, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_WCSTOMBS, CASE_4, + "should not be null terminated " + "(it may be a null char), but it is"); + } + + break; + } + + if (i == ret && ret < n) /* null termination */ + { + if (s[i] == 0) + { + Result (C_SUCCESS, S_WCSTOMBS, CASE_5, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_WCSTOMBS, CASE_5, + "should be null terminated, but it is not"); + } + + break; + } + + if (s[i] != s_ex[i]) + { + err++; + err_count++; + Result (C_FAILURE, S_WCSTOMBS, CASE_6, + "converted string is different from an " + "expected string"); + break; + } + } + + if (!err) + { + Result (C_SUCCESS, S_WCSTOMBS, CASE_6, MS_PASSED); + } + } + } + } + + return err_count; +} |