tst_towctrans.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. TOWCTRANS: wint_t towctrans (wint_t wc, wctrans_t desc);
  3. */
  4. #define TST_FUNCTION towctrans
  5. #include "tsp_common.c"
  6. #include "dat_towctrans.c"
  7. int
  8. tst_towctrans (FILE *fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (wint_t);
  11. wint_t wc;
  12. const char *ts;
  13. #if SHOJI_IS_RIGHT
  14. int dummy=0;
  15. #endif
  16. wctrans_t wto;
  17. TST_DO_TEST (towctrans)
  18. {
  19. TST_HEAD_LOCALE (towctrans, S_TOWCTRANS);
  20. TST_DO_REC (towctrans)
  21. {
  22. TST_GET_ERRET (towctrans);
  23. wc = TST_INPUT (towctrans).wc;
  24. ts = TST_INPUT (towctrans).ts;
  25. #if SHOJI_IS_RIGHT
  26. if ((wto = wctrans (ts)) == (wctrans_t) 0)
  27. {
  28. #if 0
  29. result (fp, C_IGNORED, S_TOWCTRANS, locale, rec+1, seq_num+1, 3,
  30. "Skip this data because the wctrans object is not invalid.");
  31. warn_count++;
  32. continue;
  33. #else
  34. wto = &dummy; /* not good ... */
  35. #endif
  36. if (debug_flg)
  37. {
  38. fprintf (stdout, "towctrans() ------ wctrans() returnd 0.\n");
  39. }
  40. }
  41. #else
  42. wto = wctrans (ts);
  43. #endif
  44. TST_CLEAR_ERRNO;
  45. ret = towctrans (wc, wto);
  46. TST_SAVE_ERRNO;
  47. if (debug_flg)
  48. {
  49. fprintf (stdout, "towctrans() [ %s : %d ] ret = 0x%x\n",
  50. locale, rec+1, ret);
  51. fprintf (stdout, " errno = %d\n",
  52. errno_save);
  53. }
  54. TST_IF_RETURN (S_TOWCTRANS)
  55. {
  56. if (ret != 0)
  57. {
  58. result (fp, C_SUCCESS, S_TOWCTRANS, locale, rec+1,
  59. seq_num+1, 3, MS_PASSED);
  60. }
  61. else
  62. {
  63. err_count++;
  64. result (fp, C_FAILURE, S_TOWCTRANS, locale, rec+1,
  65. seq_num+1, 3,
  66. "the function returned 0, but should be non-zero");
  67. }
  68. }
  69. }
  70. }
  71. return err_count;
  72. }