tst_strcoll.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. STRCOLL: int strcoll (const char *s1, const char *s2)
  3. */
  4. #define TST_FUNCTION strcoll
  5. #include "tsp_common.c"
  6. #include "dat_strcoll.c"
  7. int
  8. tst_strcoll (FILE * fp, int debug_flg)
  9. {
  10. TST_DECL_VARS (int);
  11. const char *s1, *s2;
  12. TST_DO_TEST (strcoll)
  13. {
  14. TST_HEAD_LOCALE (strcoll, S_STRCOLL);
  15. TST_DO_REC (strcoll)
  16. {
  17. TST_GET_ERRET (strcoll);
  18. s1 = TST_INPUT (strcoll).s1;
  19. s2 = TST_INPUT (strcoll).s2;
  20. TST_CLEAR_ERRNO;
  21. ret = strcoll (s1, s2);
  22. TST_SAVE_ERRNO;
  23. if (debug_flg)
  24. {
  25. fprintf (stdout, "strcoll() [ %s : %d ] ret = %d\n", locale,
  26. rec + 1, ret);
  27. fprintf (stdout, " errno = %d\n",
  28. errno_save);
  29. fprintf (stdout, " LC_COLLATE = %s\n",
  30. (setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
  31. NULL) : "");
  32. }
  33. TST_IF_RETURN (S_STRCOLL)
  34. {
  35. if (ret_exp == +1)
  36. {
  37. if (ret > 0)
  38. {
  39. Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
  40. }
  41. else
  42. {
  43. err_count++;
  44. Result (C_FAILURE, S_STRCOLL, CASE_3,
  45. "the return value should be greater than 0,"
  46. " but is not ...");
  47. }
  48. }
  49. else if (ret_exp == -1)
  50. {
  51. if (ret < 0)
  52. {
  53. Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
  54. }
  55. else
  56. {
  57. err_count++;
  58. Result (C_FAILURE, S_STRCOLL, CASE_3,
  59. "the return value should less than 0, but not ...");
  60. }
  61. }
  62. else if (ret_exp != 0)
  63. {
  64. if (debug_flg)
  65. {
  66. fprintf (stderr, "*** Warning *** : tst_strcoll : "
  67. "(check the test data); should set ret_flg=1"
  68. " to check a return value");
  69. }
  70. warn_count++;
  71. Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data); "
  72. "should set ret_flg=1 to check a return value");
  73. }
  74. }
  75. }
  76. }
  77. return err_count;
  78. }