• 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 <string.h>
17 #include "functionalext.h"
18 
19 #define TEST_AT_FDCWD (-100)
20 #define TEST_ERROR_AT_FDCWD 100
21 
22 /**
23  * @tc.name      : memrchr_0100
24  * @tc.desc      : Search for a character in the specified memory block
25  * @tc.level     : Level 0
26  */
memrchr_0100(void)27 void memrchr_0100(void)
28 {
29     const char *src = "this is memrchr_0100 test.";
30 
31     char *ret = memrchr(src, 'r', strlen(src));
32     EXPECT_PTRNE("memrchr_0100", ret, NULL);
33     EXPECT_STREQ("memrchr_0100", ret, "r_0100 test.");
34 
35     ret = memrchr(src, 'r', strlen("memrchr_0100 test."));
36     EXPECT_PTRNE("memrchr_0100", ret, NULL);
37     EXPECT_STREQ("memrchr_0100", ret, "r_0100 test.");
38 
39     ret = memrchr(src, 'w', strlen(src));
40     EXPECT_PTREQ("memrchr_0100", ret, NULL);
41 }
42 
43 /**
44  * @tc.name      : memrchr_0200
45  * @tc.desc      : Provide an exception parameter to search for characters in the specified memory block
46  * @tc.level     : Level 2
47  */
memrchr_0200(void)48 void memrchr_0200(void)
49 {
50     const char *src = "this is memrchr_0200 test.";
51     char *ret = memrchr(src, 'r', 0);
52     EXPECT_PTREQ("memrchr_0200", ret, NULL);
53 }
54 
main(void)55 int main(void)
56 {
57     memrchr_0100();
58     memrchr_0200();
59     return t_status;
60 }