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