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