Back to index

glibc  2.9
tst_mblen.c
Go to the documentation of this file.
00001 /*
00002   MBLEN: int mblen (char *s, size_t n)
00003 */
00004 
00005 #define TST_FUNCTION mblen
00006 
00007 #include "tsp_common.c"
00008 #include "dat_mblen.c"
00009 
00010 int
00011 tst_mblen (FILE * fp, int debug_flg)
00012 {
00013   TST_DECL_VARS (int);
00014   char s_flg;
00015   const char *s_in;
00016   size_t n;
00017 
00018   TST_DO_TEST (mblen)
00019   {
00020     TST_HEAD_LOCALE (mblen, S_MBLEN);
00021     TST_DO_REC (mblen)
00022     {
00023       TST_GET_ERRET (mblen);
00024       s_flg = TST_INPUT (mblen).s_flg;
00025       s_in = TST_INPUT (mblen).s;
00026       n = TST_INPUT (mblen).n;
00027 
00028       if (s_flg == 0)
00029        {
00030          s_in = NULL;
00031        }
00032 
00033       if (n == USE_MBCURMAX)
00034        {
00035          n = MB_CUR_MAX;
00036        }
00037 
00038       TST_CLEAR_ERRNO;
00039       ret = mblen (s_in, n);
00040       TST_SAVE_ERRNO;
00041 
00042       TST_IF_RETURN (S_MBLEN)
00043       {
00044        if (s_in == NULL)
00045          {                  /* state dependency */
00046            if (ret_exp == +1)
00047              {                     /* state-dependent  */
00048               if (ret != 0)
00049                 {
00050                   /* non-zero: state-dependent encoding */
00051                   Result (C_SUCCESS, S_MBLEN, CASE_3, MS_PASSED);
00052                 }
00053               else
00054                 {
00055                   err_count++;
00056                   Result (C_FAILURE, S_MBLEN, CASE_3,
00057                          "should be state-dependent encoding, "
00058                          "but the return value shows it is"
00059                          " state-independent");
00060                 }
00061              }
00062 
00063            if (ret_exp == 0)
00064              {                     /* state-independent */
00065               if (ret == 0)
00066                 {
00067                   /* non-zero: state-dependent encoding */
00068                   Result (C_SUCCESS, S_MBLEN, CASE_3, MS_PASSED);
00069                 }
00070               else
00071                 {
00072                   err_count++;
00073                   Result (C_FAILURE, S_MBLEN, CASE_3,
00074                          "should be state-independent encoding, "
00075                          "but the return value shows it is"
00076                          " state-dependent");
00077                 }
00078              }
00079          }
00080       }
00081     }
00082   }
00083 
00084   return err_count;
00085 }