• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <wchar.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include "test.h"
20 
21 /**
22  * @tc.name      : wcsrtombs_0100
23  * @tc.desc      : Test the result of wcspbrk when the target character is punctuation
24  * @tc.level     : Level 0
25  */
wcsrtombs_0100(void)26 void wcsrtombs_0100(void)
27 {
28     char str[256] = {0};
29     int want = 6;
30     const wchar_t *src = L"ABCDEF";
31     size_t result = wcsrtombs(str, &src, 10, NULL);
32     if (result != want) {
33         t_error("%s wcsrtombs error get result is %d are not 6", __func__, result);
34     }
35 }
36 
37 /**
38  * @tc.name      : wcsrtombs_0200
39  * @tc.desc      : Test the result of wcsrtombs when the incoming number is less than the length of the wide string
40  * @tc.level     : Level 1
41  */
wcsrtombs_0200(void)42 void wcsrtombs_0200(void)
43 {
44     char str[256] = {0};
45     const wchar_t *src = L"ABCDEF";
46     size_t result = wcsrtombs(str, &src, 0, NULL);
47     if (result != 0) {
48         t_error("%s wcsrtombs error get result is %d are not 0", __func__, result);
49     }
50 }
51 
main(int argc,char * argv[])52 int main(int argc, char *argv[])
53 {
54     wcsrtombs_0100();
55     wcsrtombs_0200();
56     return t_status;
57 }