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