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      : wmemset_0100
23  * @tc.desc      : Copies the specified number of wide characters from the source to the destination
24  * @tc.level     : Level 0
25  */
wmemset_0100(void)26 void wmemset_0100(void)
27 {
28     const int index = 20;
29     int count = 10;
30     wchar_t ch = L'C';
31     wchar_t des[index];
32     wmemset(des, ch, count);
33     for (int i = 0; i < count; i++) {
34         if (des[i] != ch) {
35             t_error("%s des[%d] is not C\n", __func__, i);
36         }
37     }
38 }
39 
40 /**
41  * @tc.name      : wmemset_0200
42  * @tc.desc      : Test wmemset when count is 0
43  * @tc.level     : Level 1
44  */
wmemset_0200(void)45 void wmemset_0200(void)
46 {
47     const int index = 10;
48     int count = 0;
49     wchar_t ch = L'C';
50     wchar_t des[index];
51     wmemset(des, ch, count);
52     for (int i = 0; i < index; i++) {
53         if (des[i] == ch) {
54             t_error("%s des[%d] is not want C\n", __func__, i);
55         }
56     }
57 }
58 
59 /**
60  * @tc.name      : wmemset_0300
61  * @tc.desc      : Test wmemset when count is equal to the number characters in dest string
62  * @tc.level     : Level 1
63  */
wmemset_0300(void)64 void wmemset_0300(void)
65 {
66     const int index = 10;
67     int count = 10;
68     wchar_t ch = L'C';
69     wchar_t des[index];
70     wmemset(des, ch, count);
71     for (int i = 0; i < index; i++) {
72         if (des[i] != ch) {
73             t_error("%s des[%d] is not want C\n", __func__, i);
74         }
75     }
76 }
77 
main(int argc, char *argv[])78 int main(int argc, char *argv[])
79 {
80     wmemset_0100();
81     wmemset_0200();
82     wmemset_0300();
83     return t_status;
84 }