diff options
author | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
commit | 5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch) | |
tree | 4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/localedata/tests-mbwc/tst_strxfrm.c | |
parent | 199fc19d3aaaf57944ef036e15904febe877fc93 (diff) | |
download | glibc-zack/build-layout-experiment.tar glibc-zack/build-layout-experiment.tar.gz glibc-zack/build-layout-experiment.tar.bz2 glibc-zack/build-layout-experiment.zip |
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/localedata/tests-mbwc/tst_strxfrm.c')
-rw-r--r-- | REORG.TODO/localedata/tests-mbwc/tst_strxfrm.c | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/REORG.TODO/localedata/tests-mbwc/tst_strxfrm.c b/REORG.TODO/localedata/tests-mbwc/tst_strxfrm.c new file mode 100644 index 0000000000..fdfeffc892 --- /dev/null +++ b/REORG.TODO/localedata/tests-mbwc/tst_strxfrm.c @@ -0,0 +1,136 @@ +/* + STRXFRM: size_t strxfrm (char *s1, const char *s2, size_t n) +*/ + +#define TST_FUNCTION strxfrm + +#include "tsp_common.c" +#include "dat_strxfrm.c" + + +int +tst_strxfrm (FILE * fp, int debug_flg) +{ + TST_DECL_VARS (size_t); + const char *org1, *org2; + char frm1[MBSSIZE], frm2[MBSSIZE]; + size_t n1, n2; + int ret_coll, ret_cmp; + + TST_DO_TEST (strxfrm) + { + TST_HEAD_LOCALE (strxfrm, S_STRXFRM); + TST_DO_REC (strxfrm) + { + TST_GET_ERRET (strxfrm); + org1 = TST_INPUT (strxfrm).org1; + org2 = TST_INPUT (strxfrm).org2; + n1 = TST_INPUT (strxfrm).n1; + n2 = TST_INPUT (strxfrm).n2; + + if (n1 < 0 || sizeof (frm1) < n1 || sizeof (frm2) < n2) + { + warn_count++; + Result (C_IGNORED, S_STRXFRM, CASE_9, + "input data n1 or n2 is invalid"); + continue; + } + + /* An errno and a return value are checked + only for 2nd strxfrm() call. + A result of 1st call is used for comparing + those 2 values by using strcmp(). + */ + + /*-- First call --*/ + + TST_CLEAR_ERRNO; + ret = strxfrm (frm1, org1, n1); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stdout, "strxfrm() [ %s : %d ] ( 1st call )\n", locale, + rec + 1); + fprintf (stdout, " : err = %d | %s\n", errno_save, + strerror (errno)); + fprintf (stdout, " : ret = %zu\n", ret); + fprintf (stdout, " : org = %s\n", org1); + } + + if (ret >= n1 || errno != 0) + { + warn_count++; + Result (C_INVALID, S_STRXFRM, CASE_8, + "got an error in fist strxfrm() call"); + continue; + } + + /*-- Second call --*/ + + TST_CLEAR_ERRNO; + ret = strxfrm (((n2 == 0) ? NULL : frm2), org2, n2); + TST_SAVE_ERRNO; + + if (debug_flg) + { + fprintf (stderr, " ..............( 2nd call )\n"); + fprintf (stdout, " : err = %d | %s\n", errno, + strerror (errno)); + fprintf (stdout, " : ret = %zu\n", ret); + fprintf (stdout, " : org = %s\n", org2); + } + + TST_IF_RETURN (S_STRXFRM) + { + }; + + if (n2 == 0 || ret >= n2 || errno != 0) + { +#if 0 + warn_count++; + Result (C_IGNORED, S_STRXFRM, CASE_7, "did not get a result"); +#endif + continue; + } + + /*-- strcoll & strcmp --*/ + + TST_CLEAR_ERRNO; + /* Depends on strcoll() ... not good though ... */ + ret_coll = strcoll (org1, org2); + + if (errno != 0) + { + /* bug * bug may get correct results ... */ + warn_count++; + Result (C_INVALID, S_STRXFRM, CASE_6, + "got an error in strcoll() call"); + continue; + } + + ret_cmp = strcmp (frm1, frm2); + + if ((ret_coll == 0 && ret_cmp == 0) + || (ret_coll < 0 && ret_cmp < 0) || (ret_coll > 0 && ret_cmp > 0)) + { + Result (C_SUCCESS, S_STRXFRM, CASE_3, + MS_PASSED "(depends on strcoll & strcmp)"); + } + else + { + err_count++; + Result (C_FAILURE, S_STRXFRM, CASE_3, + "results from strcoll & strcmp() do not match"); + } + + if (debug_flg) + { + fprintf (stdout, ".......... strcoll = %d <-> %d = strcmp\n", + ret_coll, ret_cmp); + } + } + } + + return err_count; +} |