• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include <string.h>
3 
4 using namespace testing::ext;
5 
6 class StringMemrchrTest : public testing::Test {
SetUp()7     void SetUp() override {}
TearDown()8     void TearDown() override {}
9 };
10 
11 /**
12  * @tc.name: memrchr_001
13  * @tc.desc: Validate the behavior of the memrchr function when the specified character is not found in the given
14  *           string.
15  * @tc.type: FUNC
16  */
17 HWTEST_F(StringMemrchrTest, memrchr_001, TestSize.Level1)
18 {
19     const char str[] = "hello, world";
20     const char* result = static_cast<const char*>(memrchr(str, 'z', strlen(str)));
21     EXPECT_EQ(result, nullptr);
22 }
23 
24 /**
25  * @tc.name: memrchr_002
26  * @tc.desc: Validate the behavior of the memrchr function when given a null pointer and a length of 0.
27  * @tc.type: FUNC
28  */
29 HWTEST_F(StringMemrchrTest, memrchr_002, TestSize.Level1)
30 {
31     const char* str = nullptr;
32     const char* result = static_cast<const char*>(memrchr(str, 'o', 0));
33     EXPECT_EQ(result, nullptr);
34 }