tst_wcschr.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. WCSCHR: wchar_t *wcschr (wchar_t *ws, wchar_t wc);
  3. */
  4. #define TST_FUNCTION wcschr
  5. #include "tsp_common.c"
  6. #include "dat_wcschr.c"
  7. int
  8. tst_wcschr (FILE * fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (wchar_t *);
  11. wchar_t *ws, wc;
  12. TST_DO_TEST (wcschr)
  13. {
  14. TST_HEAD_LOCALE (wcschr, S_WCSCHR);
  15. TST_DO_REC (wcschr)
  16. {
  17. TST_GET_ERRET (wcschr);
  18. ws = TST_INPUT (wcschr).ws; /* external value: size WCSSIZE */
  19. wc = TST_INPUT (wcschr).wc;
  20. ret = wcschr (ws, wc);
  21. if (debug_flg)
  22. {
  23. if (ret)
  24. {
  25. fprintf (stderr, "wcschr: ret = 0x%lx\n",
  26. (unsigned long int) *ret);
  27. }
  28. else
  29. {
  30. fprintf (stderr, "wcschr: ret = NULL pointer\n");
  31. }
  32. }
  33. TST_IF_RETURN (S_WCSCHR)
  34. {
  35. if (ret == NULL)
  36. {
  37. if (debug_flg)
  38. {
  39. fprintf (stderr, "*** Warning *** tst_wcschr: "
  40. "set ret_flg=1 to check NULL return value\n");
  41. }
  42. warn_count++;
  43. Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data) "
  44. "set ret_flg=1 to check NULL return value");
  45. continue;
  46. }
  47. if (*ret == wc)
  48. {
  49. Result (C_SUCCESS, S_WCSCHR, CASE_3, MS_PASSED);
  50. }
  51. else
  52. {
  53. err_count++;
  54. Result (C_FAILURE, S_WCSCHR, CASE_3,
  55. "the returned address of the string seems to be wrong");
  56. }
  57. }
  58. }
  59. }
  60. return err_count;
  61. }