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 <stdlib.h>
17 #include <wchar.h>
18 #include "functionalext.h"
19
20 #define SIZE 128
21 #define INIT_ERROR_VALUE 0x01
22
23 /**
24 * @tc.name : mbsinit_0100
25 * @tc.desc : Verify mbsinit process success and return nonzero value when st points to an mbstate_t object
26 * that describes the initial transition state.
27 * @tc.leve : Level 0
28 */
mbsinit_0100(void)29 void mbsinit_0100(void)
30 {
31 mbstate_t mbst;
32 memset(&mbst, 0, sizeof(mbst));
33 int ret = mbsinit(&mbst);
34 EXPECT_NE("mbsinit_0100", ret, 0);
35 }
36
37 /**
38 * @tc.name : mbsinit_0200
39 * @tc.desc : Verify mbsinit process success and return nonzero value when st is null.
40 * @tc.leve : Level 0
41 */
mbsinit_0200(void)42 void mbsinit_0200(void)
43 {
44 int ret = mbsinit(NULL);
45 EXPECT_NE("mbsinit_0200", ret, 0);
46 }
47
48 /**
49 * @tc.name : mbsinit_0300
50 * @tc.desc : Verify mbsinit process success and return zero value when when st points to an mbstate_t object
51 * that not describes the initial transition state.
52 * @tc.leve : Level 1
53 */
mbsinit_0300(void)54 void mbsinit_0300(void)
55 {
56 mbstate_t mbst;
57 memset(&mbst, INIT_ERROR_VALUE, sizeof(mbst));
58 int ret = mbsinit(&mbst);
59 EXPECT_EQ("mbsinit_0300", ret, 0);
60 }
61
main(void)62 int main(void)
63 {
64 mbsinit_0100();
65 mbsinit_0200();
66 mbsinit_0300();
67 return t_status;
68 }