Back to index

glibc  2.9
tst_wcsstr.c
Go to the documentation of this file.
00001 /*
00002   WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2);
00003 */
00004 
00005 #define TST_FUNCTION wcsstr
00006 
00007 #include "tsp_common.c"
00008 #include "dat_wcsstr.c"
00009 
00010 int
00011 tst_wcsstr (FILE * fp, int debug_flg)
00012 {
00013   TST_DECL_VARS (wchar_t *);
00014   wchar_t *ws1, *ws2;
00015   int err, i;
00016 
00017   TST_DO_TEST (wcsstr)
00018   {
00019     TST_HEAD_LOCALE (wcsstr, S_WCSSTR);
00020     TST_DO_REC (wcsstr)
00021     {
00022       TST_GET_ERRET (wcsstr);
00023       ws1 = TST_INPUT (wcsstr).ws1;
00024       ws2 = TST_INPUT (wcsstr).ws2;       /* external value: size WCSSIZE */
00025       ret = wcsstr (ws1, ws2);
00026 
00027       if (debug_flg)
00028        {
00029          fprintf (stderr, "wcsstr: %d : ret = %s\n", rec + 1,
00030                  (ret == NULL) ? "null" : "not null");
00031          if (ret)
00032            {
00033              fprintf (stderr,
00034                      "      ret[ 0 ] = 0x%lx <-> 0x%lx = ws2[ 0 ]\n",
00035                      (unsigned long int) ret[0], (unsigned long int) ws2[0]);
00036            }
00037        }
00038 
00039       TST_IF_RETURN (S_WCSSTR)
00040       {
00041        if (ws2[0] == 0)
00042          {
00043            if (ret == ws1)
00044              {
00045               Result (C_SUCCESS, S_WCSSTR, CASE_3, MS_PASSED);
00046              }
00047            else
00048              {
00049               err_count++;
00050               Result (C_FAILURE, S_WCSSTR, CASE_3,
00051                      "return address is not same address as ws1");
00052              }
00053 
00054            continue;
00055          }
00056 
00057        for (i = 0, err = 0; *(ws2 + i) != 0 && i < WCSSIZE; i++)
00058          {
00059            if (debug_flg)
00060              {
00061               fprintf (stderr,
00062                       "     : ret[ %d ] = 0x%lx <-> 0x%lx = ws2[ %d ]\n",
00063                       i, (unsigned long int) ret[i],
00064                       (unsigned long int) ws2[i], i);
00065              }
00066 
00067            if (ret[i] != ws2[i])
00068              {
00069               err++;
00070               err_count++;
00071               Result (C_FAILURE, S_WCSSTR, CASE_4, "pointed sub-string is "
00072                      "different from an expected sub-string");
00073               break;
00074              }
00075          }
00076 
00077        if (!err)
00078          {
00079            Result (C_SUCCESS, S_WCSSTR, CASE_4, MS_PASSED);
00080          }
00081       }
00082     }
00083   }
00084 
00085   return err_count;
00086 }