tst_wcscpy.c 1.8 KB

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