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 <string.h>
18 #include "functionalext.h"
19
20 const int32_t compareLength = 3;
21
22 /**
23 * @tc.name : strncasecmp_0100
24 * @tc.desc : Verify strncasecmp process success when fist string equal second stirng
25 * @tc.level : Level 0
26 */
strncasecmp_0100(void)27 void strncasecmp_0100(void)
28 {
29 int32_t ret = strncasecmp("aBcDeF", "AbCdEf", compareLength);
30 EXPECT_EQ("strncasecmp_0100", ret, 0);
31 }
32
33 /**
34 * @tc.name : strncasecmp_0200
35 * @tc.desc : Verify strncasecmp process success when fist string equal second stirng and compare length is 0
36 * @tc.level : Level 1
37 */
strncasecmp_0200(void)38 void strncasecmp_0200(void)
39 {
40 int32_t ret = strncasecmp("aBcDeF", "AbCdEf", 0);
41 EXPECT_EQ("strncasecmp_0200", ret, 0);
42 }
43
44 /**
45 * @tc.name : strncasecmp_0300
46 * @tc.desc : Verify strcasecmp process success when fist string less than second stirng
47 * @tc.level : Level 1
48 */
strncasecmp_0300(void)49 void strncasecmp_0300(void)
50 {
51 int32_t ret = strncasecmp("", "AbCdEf", compareLength);
52 EXPECT_LT("strcasecmp_0300", ret, 0);
53 }
54
55 /**
56 * @tc.name : strncasecmp_0400
57 * @tc.desc : Verify strncasecmp process success when fist string more than second stirng
58 * @tc.level : Level 1
59 */
strncasecmp_0400(void)60 void strncasecmp_0400(void)
61 {
62 int32_t ret = strncasecmp("AbCdEf", "", compareLength);
63 EXPECT_MT("strncasecmp_0400", ret, 0);
64 }
65
66 /**
67 * @tc.name : strncasecmp_0500
68 * @tc.desc : Verify strncasecmp process success when fist string is null second stirng is null
69 * @tc.level : Level 1
70 */
strncasecmp_0500(void)71 void strncasecmp_0500(void)
72 {
73 int32_t ret = strncasecmp("", "", 3);
74 EXPECT_EQ("strncasecmp_0500", ret, 0);
75 }
76
main(void)77 int main(void)
78 {
79 strncasecmp_0100();
80 strncasecmp_0200();
81 strncasecmp_0300();
82 strncasecmp_0400();
83 strncasecmp_0500();
84 return t_status;
85 }
86