tst_wcscat.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. WCSCAT: wchar_t *wcscat (wchar_t *ws1, const wchar_t *ws2);
  3. */
  4. #define TST_FUNCTION wcscat
  5. #include "tsp_common.c"
  6. #include "dat_wcscat.c"
  7. int
  8. tst_wcscat (FILE * fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (wchar_t *);
  11. wchar_t *ws1, *ws2, *ws_ex;
  12. int i, err;
  13. TST_DO_TEST (wcscat)
  14. {
  15. TST_HEAD_LOCALE (wcscat, S_WCSCAT);
  16. TST_DO_REC (wcscat)
  17. {
  18. TST_GET_ERRET (wcscat);
  19. ws1 = TST_INPUT (wcscat).ws1; /* external value: size WCSSIZE */
  20. ws2 = TST_INPUT (wcscat).ws2;
  21. TST_CLEAR_ERRNO;
  22. ret = wcscat (ws1, ws2);
  23. TST_SAVE_ERRNO;
  24. TST_IF_RETURN (S_WCSCAT)
  25. {
  26. if (ret == ws1)
  27. {
  28. Result (C_SUCCESS, S_WCSCAT, CASE_3, MS_PASSED);
  29. }
  30. else
  31. {
  32. err_count++;
  33. Result (C_FAILURE, S_WCSCAT, CASE_3,
  34. "the return address may not be correct");
  35. }
  36. }
  37. /* function specific test cases here */
  38. if (ret == ws1)
  39. {
  40. ws_ex = TST_EXPECT (wcscat).ws;
  41. for (err = 0, i = 0;
  42. (ws1[i] != 0L || ws_ex[i] != 0L) && i < WCSSIZE; i++)
  43. {
  44. if (debug_flg)
  45. {
  46. fprintf (stdout, "tst_wcscat() : ws1[%d] = 0x%lx\n", i,
  47. (unsigned long int) ws1[i]);
  48. }
  49. if (ws1[i] != ws_ex[i])
  50. {
  51. err++;
  52. err_count++;
  53. Result (C_FAILURE, S_WCSCAT, CASE_4,
  54. "concatinated string is different from an "
  55. "expected string");
  56. break;
  57. }
  58. }
  59. if (!err)
  60. {
  61. Result (C_SUCCESS, S_WCSCAT, CASE_4, MS_PASSED);
  62. }
  63. }
  64. }
  65. }
  66. return err_count;
  67. }