1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <signal.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <wchar.h>
20 #include "test.h"
21
22 #define MAX (20)
23
handler(int sig)24 void handler(int sig)
25 {
26 exit(t_status);
27 }
28
29 /**
30 * @tc.name : wcscat_0100
31 * @tc.desc : Concatenate wide strings
32 * @tc.level : Level 0
33 */
wcscat_0100(void)34 void wcscat_0100(void)
35 {
36 wchar_t dest[MAX] = L"wcscat ";
37 wchar_t src[MAX] = L"test";
38 wcscat(dest, src);
39 if (wcscmp(dest, L"wcscat test")) {
40 t_error("%s concatenate wide strings failed\n", __func__);
41 }
42 }
43
44 /**
45 * @tc.name : wcscat_0200
46 * @tc.desc : destination and source overlap.
47 * @tc.level : Level 2
48 */
wcscat_0200(void)49 void wcscat_0200(void)
50 {
51 signal(SIGSEGV, handler);
52
53 wchar_t dest[MAX] = L"wcscat ";
54 wchar_t *src = &dest[1];
55 wcscat(dest, src);
56 }
57
main(int argc,char * argv[])58 int main(int argc, char *argv[])
59 {
60 wcscat_0100();
61 wcscat_0200();
62 return t_status;
63 }