tst_wcstok.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, wchar_t **pt);
  3. */
  4. #define TST_FUNCTION wcstok
  5. #include "tsp_common.c"
  6. #include "dat_wcstok.c"
  7. int
  8. tst_wcstok (FILE * fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (wchar_t *);
  11. char w_flg;
  12. wchar_t *ws;
  13. wchar_t *dt, *pt;
  14. wchar_t *ws_ex;
  15. int err, i;
  16. TST_DO_TEST (wcstok)
  17. {
  18. TST_HEAD_LOCALE (wcstok, S_WCSTOK);
  19. TST_DO_REC (wcstok)
  20. {
  21. TST_DO_SEQ (WCSTOK_SEQNUM)
  22. {
  23. TST_GET_ERRET_SEQ (wcstok);
  24. w_flg = TST_INPUT_SEQ (wcstok).w_flg;
  25. ws = (w_flg) ? TST_INPUT_SEQ (wcstok).ws : NULL;
  26. dt = TST_INPUT_SEQ (wcstok).dt;
  27. ret = wcstok (ws, dt, &pt);
  28. if (debug_flg)
  29. {
  30. fprintf (stdout, "wcstok() [ %s : %d : %d ] *ret = 0x%lx\n",
  31. locale, rec + 1, seq_num + 1, (unsigned long int) *ret);
  32. if (pt && *pt)
  33. {
  34. fprintf (stdout, " *pt = 0x%lx\n",
  35. (unsigned long int) *pt);
  36. }
  37. }
  38. TST_IF_RETURN (S_WCSTOK)
  39. {
  40. };
  41. if (ret != NULL)
  42. {
  43. ws_ex = TST_EXPECT_SEQ (wcstok).ws;
  44. /* XXX: REVISIT : insufficient conditions */
  45. for (err = 0, i = 0; i < WCSSIZE; i++)
  46. {
  47. if (ret[i] == L'\0' && ws_ex[i] == L'\0')
  48. {
  49. break;
  50. }
  51. if (debug_flg)
  52. {
  53. fprintf (stderr,
  54. " ret[%d] = 0x%lx <-> "
  55. "0x%lx = ws_ex[%d]\n",
  56. i, (unsigned long int) ret[i],
  57. (unsigned long int) ws_ex[i], i);
  58. }
  59. if (ret[i] != ws_ex[i])
  60. {
  61. err++;
  62. err_count++;
  63. Result (C_FAILURE, S_WCSTOK, CASE_3,
  64. "the token is different from an expected string");
  65. break;
  66. }
  67. if (ret[i] == L'\0' || ws_ex[i] == L'\0')
  68. {
  69. break;
  70. }
  71. }
  72. if (!err)
  73. {
  74. Result (C_SUCCESS, S_WCSTOK, CASE_3, MS_PASSED);
  75. }
  76. }
  77. }
  78. }
  79. }
  80. return err_count;
  81. }