(root)/
glibc-2.38/
localedata/
tests-mbwc/
tst_wcsstr.c
       1  /*
       2    WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2);
       3  */
       4  
       5  #define TST_FUNCTION wcsstr
       6  
       7  #include "tsp_common.c"
       8  #include "dat_wcsstr.c"
       9  
      10  int
      11  tst_wcsstr (FILE * fp, int debug_flg)
      12  {
      13    TST_DECL_VARS (wchar_t *);
      14    wchar_t *ws1, *ws2;
      15    int err, i;
      16  
      17    TST_DO_TEST (wcsstr)
      18    {
      19      TST_HEAD_LOCALE (wcsstr, S_WCSSTR);
      20      TST_DO_REC (wcsstr)
      21      {
      22        TST_GET_ERRET (wcsstr);
      23        ws1 = TST_INPUT (wcsstr).ws1;
      24        ws2 = TST_INPUT (wcsstr).ws2;	/* external value: size WCSSIZE */
      25        ret = wcsstr (ws1, ws2);
      26  
      27        if (debug_flg)
      28  	{
      29  	  fprintf (stderr, "wcsstr: %d : ret = %s\n", rec + 1,
      30  		   (ret == NULL) ? "null" : "not null");
      31  	  if (ret)
      32  	    {
      33  	      fprintf (stderr,
      34  		       "	ret[ 0 ] = 0x%lx <-> 0x%lx = ws2[ 0 ]\n",
      35  		       (unsigned long int) ret[0], (unsigned long int) ws2[0]);
      36  	    }
      37  	}
      38  
      39        TST_IF_RETURN (S_WCSSTR)
      40        {
      41  	if (ws2[0] == 0)
      42  	  {
      43  	    if (ret == ws1)
      44  	      {
      45  		Result (C_SUCCESS, S_WCSSTR, CASE_3, MS_PASSED);
      46  	      }
      47  	    else
      48  	      {
      49  		err_count++;
      50  		Result (C_FAILURE, S_WCSSTR, CASE_3,
      51  			"return address is not same address as ws1");
      52  	      }
      53  
      54  	    continue;
      55  	  }
      56  
      57  	for (i = 0, err = 0; *(ws2 + i) != 0 && i < WCSSIZE; i++)
      58  	  {
      59  	    if (debug_flg)
      60  	      {
      61  		fprintf (stderr,
      62  			 "	: ret[ %d ] = 0x%lx <-> 0x%lx = ws2[ %d ]\n",
      63  			 i, (unsigned long int) ret[i],
      64  			 (unsigned long int) ws2[i], i);
      65  	      }
      66  
      67  	    if (ret[i] != ws2[i])
      68  	      {
      69  		err++;
      70  		err_count++;
      71  		Result (C_FAILURE, S_WCSSTR, CASE_4, "pointed sub-string is "
      72  			"different from an expected sub-string");
      73  		break;
      74  	      }
      75  	  }
      76  
      77  	if (!err)
      78  	  {
      79  	    Result (C_SUCCESS, S_WCSSTR, CASE_4, MS_PASSED);
      80  	  }
      81        }
      82      }
      83    }
      84  
      85    return err_count;
      86  }