tst_wcscoll.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. WCSCOLL: int wcscoll (const wchar_t *ws1, const wchar_t *ws2);
  3. */
  4. #define TST_FUNCTION wcscoll
  5. #include "tsp_common.c"
  6. #include "dat_wcscoll.c"
  7. int
  8. tst_wcscoll (FILE * fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (int);
  11. wchar_t *ws1, *ws2;
  12. int cmp;
  13. TST_DO_TEST (wcscoll)
  14. {
  15. TST_HEAD_LOCALE (wcscoll, S_WCSCOLL);
  16. TST_DO_REC (wcscoll)
  17. {
  18. TST_GET_ERRET (wcscoll);
  19. ws1 = TST_INPUT (wcscoll).ws1; /* external value: size WCSSIZE */
  20. ws2 = TST_INPUT (wcscoll).ws2;
  21. TST_CLEAR_ERRNO;
  22. ret = wcscoll (ws1, ws2);
  23. TST_SAVE_ERRNO;
  24. if (debug_flg)
  25. {
  26. fprintf (stderr, "tst_wcscoll: ret = %d\n", ret);
  27. }
  28. cmp = TST_EXPECT (wcscoll).cmp_flg;
  29. TST_IF_RETURN (S_WCSCOLL)
  30. {
  31. if (cmp != 0)
  32. {
  33. if ((cmp == 1 && ret > 0) || (cmp == -1 && ret < 0))
  34. {
  35. Result (C_SUCCESS, S_WCSCOLL, CASE_3, MS_PASSED);
  36. }
  37. else
  38. {
  39. err_count++;
  40. if (cmp == 1)
  41. {
  42. if (ret == 0)
  43. Result (C_FAILURE, S_WCSCOLL, CASE_3,
  44. "the return value should be positive"
  45. " but it's zero.");
  46. else
  47. Result (C_FAILURE, S_WCSCOLL, CASE_3,
  48. "the return value should be positive"
  49. " but it's negative.");
  50. }
  51. else
  52. {
  53. if (ret == 0)
  54. Result (C_FAILURE, S_WCSCOLL, CASE_3,
  55. "the return value should be negative"
  56. " but it's zero.");
  57. else
  58. Result (C_FAILURE, S_WCSCOLL, CASE_3,
  59. "the return value should be negative"
  60. " but it's positive.");
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. return err_count;
  68. }