Back to index

glibc  2.9
tst_wcstok.c
Go to the documentation of this file.
00001 /*
00002   WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, wchar_t **pt);
00003 */
00004 
00005 
00006 #define TST_FUNCTION wcstok
00007 
00008 #include "tsp_common.c"
00009 #include "dat_wcstok.c"
00010 
00011 int
00012 tst_wcstok (FILE * fp, int debug_flg)
00013 {
00014   TST_DECL_VARS (wchar_t *);
00015   char w_flg;
00016   wchar_t *ws;
00017   wchar_t *dt, *pt;
00018   wchar_t *ws_ex;
00019   int err, i;
00020 
00021   TST_DO_TEST (wcstok)
00022   {
00023     TST_HEAD_LOCALE (wcstok, S_WCSTOK);
00024     TST_DO_REC (wcstok)
00025     {
00026       TST_DO_SEQ (WCSTOK_SEQNUM)
00027       {
00028        TST_GET_ERRET_SEQ (wcstok);
00029        w_flg = TST_INPUT_SEQ (wcstok).w_flg;
00030        ws = (w_flg) ? TST_INPUT_SEQ (wcstok).ws : NULL;
00031        dt = TST_INPUT_SEQ (wcstok).dt;
00032 
00033        ret = wcstok (ws, dt, &pt);
00034 
00035        if (debug_flg)
00036          {
00037            fprintf (stdout, "wcstok() [ %s : %d : %d ] *ret  = 0x%lx\n",
00038                    locale, rec + 1, seq_num + 1, (unsigned long int) *ret);
00039            if (pt && *pt)
00040              {
00041               fprintf (stdout, "                  *pt   = 0x%lx\n",
00042                       (unsigned long int) *pt);
00043              }
00044          }
00045 
00046        TST_IF_RETURN (S_WCSTOK)
00047        {
00048        };
00049 
00050        if (ret != NULL)
00051          {
00052            ws_ex = TST_EXPECT_SEQ (wcstok).ws;
00053 
00054            /* XXX: REVISIT : insufficient conditions */
00055            for (err = 0, i = 0; i < WCSSIZE; i++)
00056              {
00057               if (ret[i] == L'\0' && ws_ex[i] == L'\0')
00058                 {
00059                   break;
00060                 }
00061 
00062               if (debug_flg)
00063                 {
00064                   fprintf (stderr,
00065                           "                     ret[%d] = 0x%lx <-> "
00066                           "0x%lx = ws_ex[%d]\n",
00067                           i, (unsigned long int) ret[i],
00068                           (unsigned long int) ws_ex[i], i);
00069                 }
00070 
00071               if (ret[i] != ws_ex[i])
00072                 {
00073                   err++;
00074                   err_count++;
00075                   Result (C_FAILURE, S_WCSTOK, CASE_3,
00076                          "the token is different from an expected string");
00077                   break;
00078                 }
00079 
00080               if (ret[i] == L'\0' || ws_ex[i] == L'\0')
00081                 {
00082                   break;
00083                 }
00084              }
00085 
00086            if (!err)
00087              {
00088               Result (C_SUCCESS, S_WCSTOK, CASE_3, MS_PASSED);
00089              }
00090          }
00091       }
00092     }
00093   }
00094 
00095   return err_count;
00096 }