1 /*
2   WCSTOD: double wcstod (wchar_t *np, const wchar_t **endp);
3 */
4 
5 #define TST_FUNCTION wcstod
6 
7 #include "tsp_common.c"
8 #include "dat_wcstod.c"
9 
10 int
tst_wcstod(FILE * fp,int debug_flg)11 tst_wcstod (FILE * fp, int debug_flg)
12 {
13   TST_DECL_VARS (double);
14   wchar_t *np, *endp, fwc;
15   double val;
16 
17   TST_DO_TEST (wcstod)
18   {
19     TST_HEAD_LOCALE (wcstod, S_WCSTOD);
20     TST_DO_REC (wcstod)
21     {
22       TST_GET_ERRET (wcstod);
23       np = TST_INPUT (wcstod).np;
24 
25       TST_CLEAR_ERRNO;
26       ret = wcstod (np, &endp);
27       TST_SAVE_ERRNO;
28 
29       if (debug_flg)
30 	{
31 	  fprintf (stdout, "wcstod() [ %s : %d ] ret  = %f\n", locale,
32 		   rec + 1, ret);
33 	  fprintf (stdout, "			  *endp = 0x%lx\n",
34 		   (unsigned long int) *endp);
35 	}
36 
37       TST_IF_RETURN (S_WCSTOD)
38       {
39 	if (ret != 0)
40 	  {
41 	    val = ret - TST_EXPECT (wcstod).val;
42 	    if (TST_ABS (val) < TST_DBL_EPS)
43 	      {
44 		Result (C_SUCCESS, S_WCSTOD, CASE_3, MS_PASSED);
45 	      }
46 	    else
47 	      {
48 		err_count++;
49 		Result (C_FAILURE, S_WCSTOD, CASE_3, "return value is wrong");
50 	      }
51 	  }
52       }
53 
54       fwc = TST_EXPECT (wcstod).fwc;
55 
56       if (fwc == *endp)
57 	{
58 	  Result (C_SUCCESS, S_WCSTOD, CASE_4, MS_PASSED);
59 	}
60       else
61 	{
62 	  err_count++;
63 	  Result (C_FAILURE, S_WCSTOD, CASE_4, "a final wc is wrong.");
64 	}
65     }
66   }
67 
68   return err_count;
69 }
70