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 <stdio.h>
17 #include <string.h>
18 #include <wchar.h>
19 #include "test.h"
20
21 /**
22 * @tc.name : wmemcpy_0100
23 * @tc.desc : Copies specified number of characters from one string to another
24 * @tc.level : Level 0
25 */
wmemcpy_0100(void)26 void wmemcpy_0100(void)
27 {
28 wchar_t dest[30];
29 wchar_t src[] = L"This is a c test for wmemcpy";
30 int n = 13;
31 wmemcpy(dest, src, n);
32 if (wcsncmp(dest, src, n)) {
33 t_error("%s The string of dest is not equal to src\n", __func__);
34 }
35 }
36
37 /**
38 * @tc.name : wmemcpy_0200
39 * @tc.desc : Test wmemcpy when 'n' is equal to the number characters in src string
40 * @tc.level : Level 0
41 */
wmemcpy_0200(void)42 void wmemcpy_0200(void)
43 {
44 wchar_t dest[3];
45 wchar_t src[] = L"aaa";
46 int n = 3;
47 wmemcpy(dest, src, n);
48 if (wcsncmp(dest, src, n)) {
49 t_error("%s The string of dest is not equal to src\n", __func__);
50 }
51 }
52
53 /**
54 * @tc.name : wmemcpy_0300
55 * @tc.desc : Test wmemcpy when 'n' is equal to 0
56 * @tc.level : Level 0
57 */
wmemcpy_0300(void)58 void wmemcpy_0300(void)
59 {
60 wchar_t dest[3];
61 wchar_t src[] = L"aaa";
62 int n = 0;
63 wmemcpy(dest, src, n);
64 if (!wcscmp(dest, src)) {
65 t_error("%s The string of dest is equal to src\n", __func__);
66 }
67 }
68
main(int argc,char * argv[])69 int main(int argc, char *argv[])
70 {
71 wmemcpy_0100();
72 wmemcpy_0200();
73 wmemcpy_0300();
74 return t_status;
75 }