• 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 <stdlib.h>
17 #include <string.h>
18 #include "functionalext.h"
19 
20 const int INIT_LEN = 0;
21 
22 /**
23  * @tc.name       :strlen_0100
24  * @tc.desc       :Verify strlen is successed when src is "this is a test 1234~@#$%".
25  * @tc.desc       :level 0
26  */
strlen_0100(void)27 void strlen_0100(void)
28 {
29     char src[] = "this is a test 1234~@#$%";
30     int srcLen = sizeof(src) / sizeof(src[0]) - 1;
31     int ret = strlen(src);
32     EXPECT_EQ("strlen_0100", ret, srcLen);
33 }
34 
35 /**
36  * @tc.name       :strlen_0200
37  * @tc.desc       :Verify strlen is successed when src is "测试1234~@#$%".
38  * @tc.desc       :level 1
39  */
strlen_0200(void)40 void strlen_0200(void)
41 {
42     char src[] = "测试1234~@#$%";
43     int srcLen = sizeof(src) / sizeof(src[0]) - 1;
44     int ret = strlen(src);
45     EXPECT_EQ("strlen_0200", ret, srcLen);
46 }
47 
48 /**
49  * @tc.name       :strlen_0300
50  * @tc.desc       :Verify strlen is successed when src is "".
51  * @tc.desc       :level 1
52  */
strlen_0300(void)53 void strlen_0300(void)
54 {
55     char src[] = "";
56     int srcLen = INIT_LEN;
57     int ret = strlen(src);
58     EXPECT_EQ("strlen_0300", ret, srcLen);
59 }
60 
main(void)61 int main(void)
62 {
63     strlen_0100();
64     strlen_0200();
65     strlen_0300();
66     return t_status;
67 }
68