tst_wcstod.c 1.2 KB

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