Back to index

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