tst_wcsncat.c 1.4 KB

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