Back to index

glibc  2.9
tst_wcscat.c
Go to the documentation of this file.
00001 /*
00002   WCSCAT: wchar_t *wcscat (wchar_t *ws1, const wchar_t *ws2);
00003 */
00004 
00005 #define TST_FUNCTION wcscat
00006 
00007 #include "tsp_common.c"
00008 #include "dat_wcscat.c"
00009 
00010 int
00011 tst_wcscat (FILE * fp, int debug_flg)
00012 {
00013   TST_DECL_VARS (wchar_t *);
00014   wchar_t *ws1, *ws2, *ws_ex;
00015   int i, err;
00016 
00017   TST_DO_TEST (wcscat)
00018   {
00019     TST_HEAD_LOCALE (wcscat, S_WCSCAT);
00020     TST_DO_REC (wcscat)
00021     {
00022       TST_GET_ERRET (wcscat);
00023       ws1 = TST_INPUT (wcscat).ws1;       /* external value: size WCSSIZE */
00024       ws2 = TST_INPUT (wcscat).ws2;
00025 
00026       TST_CLEAR_ERRNO;
00027       ret = wcscat (ws1, ws2);
00028       TST_SAVE_ERRNO;
00029 
00030       TST_IF_RETURN (S_WCSCAT)
00031       {
00032        if (ret == ws1)
00033          {
00034            Result (C_SUCCESS, S_WCSCAT, CASE_3, MS_PASSED);
00035          }
00036        else
00037          {
00038            err_count++;
00039            Result (C_FAILURE, S_WCSCAT, CASE_3,
00040                   "the return address may not be correct");
00041          }
00042       }
00043 
00044       /* function specific test cases here */
00045 
00046       if (ret == ws1)
00047        {
00048          ws_ex = TST_EXPECT (wcscat).ws;
00049          for (err = 0, i = 0;
00050               (ws1[i] != 0L || ws_ex[i] != 0L) && i < WCSSIZE; i++)
00051            {
00052              if (debug_flg)
00053               {
00054                 fprintf (stdout, "tst_wcscat() : ws1[%d] = 0x%lx\n", i,
00055                         (unsigned long int) ws1[i]);
00056               }
00057 
00058              if (ws1[i] != ws_ex[i])
00059               {
00060                 err++;
00061                 err_count++;
00062                 Result (C_FAILURE, S_WCSCAT, CASE_4,
00063                        "concatinated string is different from an "
00064                        "expected string");
00065                 break;
00066               }
00067            }
00068 
00069          if (!err)
00070            {
00071              Result (C_SUCCESS, S_WCSCAT, CASE_4, MS_PASSED);
00072            }
00073        }
00074     }
00075   }
00076 
00077   return err_count;
00078 }