Back to index

glibc  2.9
tst_strcoll.c
Go to the documentation of this file.
00001 /*
00002   STRCOLL: int strcoll (const char *s1, const char *s2)
00003 */
00004 
00005 #define TST_FUNCTION strcoll
00006 
00007 #include "tsp_common.c"
00008 #include "dat_strcoll.c"
00009 
00010 int
00011 tst_strcoll (FILE * fp, int debug_flg)
00012 {
00013   TST_DECL_VARS (int);
00014   const char *s1, *s2;
00015 
00016   TST_DO_TEST (strcoll)
00017   {
00018     TST_HEAD_LOCALE (strcoll, S_STRCOLL);
00019     TST_DO_REC (strcoll)
00020     {
00021       TST_GET_ERRET (strcoll);
00022       s1 = TST_INPUT (strcoll).s1;
00023       s2 = TST_INPUT (strcoll).s2;
00024 
00025       TST_CLEAR_ERRNO;
00026       ret = strcoll (s1, s2);
00027       TST_SAVE_ERRNO;
00028 
00029       if (debug_flg)
00030        {
00031          fprintf (stdout, "strcoll() [ %s : %d ] ret = %d\n", locale,
00032                  rec + 1, ret);
00033          fprintf (stdout, "                   errno = %d\n",
00034                  errno_save);
00035          fprintf (stdout, "                   LC_COLLATE = %s\n",
00036                  (setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
00037                                                         NULL) : "");
00038        }
00039 
00040       TST_IF_RETURN (S_STRCOLL)
00041       {
00042        if (ret_exp == +1)
00043          {
00044            if (ret > 0)
00045              {
00046               Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
00047              }
00048            else
00049              {
00050               err_count++;
00051               Result (C_FAILURE, S_STRCOLL, CASE_3,
00052                      "the return value should be greater than 0,"
00053                      " but is not ...");
00054              }
00055          }
00056        else if (ret_exp == -1)
00057          {
00058            if (ret < 0)
00059              {
00060               Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
00061              }
00062            else
00063              {
00064               err_count++;
00065               Result (C_FAILURE, S_STRCOLL, CASE_3,
00066                      "the return value should less than 0, but not ...");
00067              }
00068          }
00069        else if (ret_exp != 0)
00070          {
00071            if (debug_flg)
00072              {
00073               fprintf (stderr, "*** Warning *** : tst_strcoll : "
00074                       "(check the test data); should set ret_flg=1"
00075                       " to check a return value");
00076              }
00077 
00078            warn_count++;
00079            Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data); "
00080                   "should set ret_flg=1 to check a return value");
00081          }
00082       }
00083     }
00084   }
00085 
00086   return err_count;
00087 }