Back to index

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