diff options
author | Andreas Jaeger <aj@suse.de> | 2000-06-29 07:13:12 +0000 |
---|---|---|
committer | Andreas Jaeger <aj@suse.de> | 2000-06-29 07:13:12 +0000 |
commit | 2e23c3cc3fede8cc080af74f1b4f124b12955138 (patch) | |
tree | 40f76b9203246a3e70247b56743b442313179732 /localedata/tests-mbwc/tst_mbtowc.c | |
parent | 4eeccd750dce53d7b168d227cb5cfcf70d674310 (diff) | |
download | glibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.tar glibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.tar.gz glibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.tar.bz2 glibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.zip |
Update.
2000-06-29 Andreas Jaeger <aj@suse.de>
* Makefile (locale_test_suite): Add new test files.
(tst_mblen-ENV): New.
(tst_mbtowc-ENV): New.
(tst_strcoll-ENV): New.
(tst_strxfrm-ENV): New.
(tst_wctomb-ENV): New.
* tests-mbwc/tst_wctomb.c: New test file from Shoji Kuwabara
<kuwahara@cthulhu.engr.sgi.com>.
* tests-mbwc/dat_wctomb.c: Likewise.
* tests-mbwc/tst_mbtowc.c: Likewise.
* tests-mbwc/dat_mbtowc.c: Likewise.
* tests-mbwc/tst_strxfrm.c: Likewise.
* tests-mbwc/dat_strxfrm.c: Likewise.
* tests-mbwc/dat_strcoll.c: Likewise.
* tests-mbwc/tst_strcoll.c: Likewise.
* tests-mbwc/tst_mblen.c: Likewise.
* tests-mbwc/dat_mblen.c: Likewise.
Diffstat (limited to 'localedata/tests-mbwc/tst_mbtowc.c')
-rw-r--r-- | localedata/tests-mbwc/tst_mbtowc.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/localedata/tests-mbwc/tst_mbtowc.c b/localedata/tests-mbwc/tst_mbtowc.c new file mode 100644 index 0000000000..c525941f60 --- /dev/null +++ b/localedata/tests-mbwc/tst_mbtowc.c @@ -0,0 +1,126 @@ +/* + MBTOWC: int mbtowc (wchar_t *wc, char *s, size_t n) +*/ + +#define TST_FUNCTION mbtowc + +#include "tsp_common.c" +#include "dat_mbtowc.c" + + +int +tst_mbtowc (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (int); + char w_flg, s_flg; + const char *s_in; + size_t n; + wchar_t wc, wc_ex, *wp; + + TST_DO_TEST (mbtowc) + { + TST_HEAD_LOCALE (mbtowc, S_MBTOWC); + TST_DO_REC (mbtowc) + { + if (mbstowcs (NULL, "", 0) != 0) + { + err_count++; + Result (C_FAILURE, S_MBSTOWCS, CASE_3, + "Initialization failed - skipping this test case."); + continue; + } + + TST_DO_SEQ (MBTOWC_SEQNUM) + { + TST_GET_ERRET_SEQ (mbtowc); + w_flg = TST_INPUT_SEQ (mbtowc).w_flg; + s_flg = TST_INPUT_SEQ (mbtowc).s_flg; + n = TST_INPUT_SEQ (mbtowc).n; + + if (n == USE_MBCURMAX) + { + n = MB_CUR_MAX; + } + + if (s_flg == 0) + s_in = NULL; + else + s_in = TST_INPUT_SEQ (mbtowc).s; + + wp = (wchar_t *) ((w_flg == 0) ? NULL : &wc); + + TST_CLEAR_ERRNO; + ret = mbtowc (wp, s_in, n); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stdout, "mbtowc() [ %s : %d ] ret = %d\n", locale, + rec + 1, ret); + fprintf (stdout, " errno = %d\n", + errno_save); + } + + TST_IF_RETURN (S_MBTOWC) + { + if (s_in == NULL) + { /* state dependency */ + if (ret_exp == +1) + { /* state-dependent */ + if (ret != 0) + { + /* Non-zero: state-dependent encoding. */ + Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_MBTOWC, CASE_3, + "should be state-dependent encoding, " + "but a return value shows it is " + "state-independent"); + } + } + + if (ret_exp == 0) + { /* state-independent */ + if (ret == 0) + { + /* Non-zero: state-dependent encoding. */ + Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_MBTOWC, CASE_3, + "should be state-independent encoding, " + "but a return value shows it is " + "state-dependent"); + } + } + } + } + + if ((wp == NULL || s_in == NULL || s_in[0] == 0) || ret <= 0) + { + continue; + } + + wc_ex = TST_EXPECT_SEQ (mbtowc).wc; + + if (wc_ex == wc) + { + Result (C_SUCCESS, S_MBTOWC, CASE_4, MS_PASSED); + } + else + { + err_count++; + Result (C_FAILURE, S_MBTOWC, CASE_4, + "converted wc is different from an expected wc"); + } + } + } + } + + return err_count; +} |