tst_wcsstr.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2);
  3. */
  4. #define TST_FUNCTION wcsstr
  5. #include "tsp_common.c"
  6. #include "dat_wcsstr.c"
  7. int
  8. tst_wcsstr (FILE * fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (wchar_t *);
  11. wchar_t *ws1, *ws2;
  12. int err, i;
  13. TST_DO_TEST (wcsstr)
  14. {
  15. TST_HEAD_LOCALE (wcsstr, S_WCSSTR);
  16. TST_DO_REC (wcsstr)
  17. {
  18. TST_GET_ERRET (wcsstr);
  19. ws1 = TST_INPUT (wcsstr).ws1;
  20. ws2 = TST_INPUT (wcsstr).ws2; /* external value: size WCSSIZE */
  21. ret = wcsstr (ws1, ws2);
  22. if (debug_flg)
  23. {
  24. fprintf (stderr, "wcsstr: %d : ret = %s\n", rec + 1,
  25. (ret == NULL) ? "null" : "not null");
  26. if (ret)
  27. {
  28. fprintf (stderr,
  29. " ret[ 0 ] = 0x%lx <-> 0x%lx = ws2[ 0 ]\n",
  30. (unsigned long int) ret[0], (unsigned long int) ws2[0]);
  31. }
  32. }
  33. TST_IF_RETURN (S_WCSSTR)
  34. {
  35. if (ws2[0] == 0)
  36. {
  37. if (ret == ws1)
  38. {
  39. Result (C_SUCCESS, S_WCSSTR, CASE_3, MS_PASSED);
  40. }
  41. else
  42. {
  43. err_count++;
  44. Result (C_FAILURE, S_WCSSTR, CASE_3,
  45. "return address is not same address as ws1");
  46. }
  47. continue;
  48. }
  49. for (i = 0, err = 0; *(ws2 + i) != 0 && i < WCSSIZE; i++)
  50. {
  51. if (debug_flg)
  52. {
  53. fprintf (stderr,
  54. " : ret[ %d ] = 0x%lx <-> 0x%lx = ws2[ %d ]\n",
  55. i, (unsigned long int) ret[i],
  56. (unsigned long int) ws2[i], i);
  57. }
  58. if (ret[i] != ws2[i])
  59. {
  60. err++;
  61. err_count++;
  62. Result (C_FAILURE, S_WCSSTR, CASE_4, "pointed sub-string is "
  63. "different from an expected sub-string");
  64. break;
  65. }
  66. }
  67. if (!err)
  68. {
  69. Result (C_SUCCESS, S_WCSSTR, CASE_4, MS_PASSED);
  70. }
  71. }
  72. }
  73. }
  74. return err_count;
  75. }