1 #include <gtest/gtest.h> 2 #include <string.h> 3 4 using namespace testing::ext; 5 6 class StringStrcmpTest : public testing::Test { SetUp()7 void SetUp() override {} TearDown()8 void TearDown() override {} 9 }; 10 11 /** 12 * @tc.name: strcmp_001 13 * @tc.desc: Verify that the strcmp function should return 0 when comparing two completely identical strings. 14 * @tc.type: FUNC 15 */ 16 HWTEST_F(StringStrcmpTest, strcmp_001, TestSize.Level1) 17 { 18 const char* str1 = "Hello"; 19 const char* str2 = "Hello"; 20 int result = strcmp(str1, str2); 21 EXPECT_EQ(result, 0); 22 } 23 24 /** 25 * @tc.name: strcmp_002 26 * @tc.desc: Verify that the strcmp function should return a non-zero value when comparing two different strings. 27 * @tc.type: FUNC 28 */ 29 HWTEST_F(StringStrcmpTest, strcmp_002, TestSize.Level1) 30 { 31 const char* str1 = "Hello"; 32 const char* str2 = "World"; 33 int result = strcmp(str1, str2); 34 EXPECT_NE(result, 0); 35 } 36 37 /** 38 * @tc.name: strcmp_003 39 * @tc.desc: Verify that the strcmp function should return 0 when comparing two null pointer. 40 * @tc.type: FUNC 41 */ 42 HWTEST_F(StringStrcmpTest, strcmp_003, TestSize.Level1) 43 { 44 const char* str1 = nullptr; 45 const char* str2 = nullptr; 46 int result = strcmp(str1, str2); 47 EXPECT_EQ(result, 0); 48 }