• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include <string.h>
3 
4 using namespace testing::ext;
5 
6 class StringBcmpTest : public testing::Test {
SetUp()7     void SetUp() override {}
TearDown()8     void TearDown() override {}
9 };
10 
11 /**
12  * @tc.name: bcmp_001
13  * @tc.desc: Verify that the bcmp function returns the expected result of 0 when comparing two strings with identical
14  *           content.
15  * @tc.type: FUNC
16  */
17 HWTEST_F(StringBcmpTest, bcmp_001, TestSize.Level1)
18 {
19     const char* str1 = "Hello";
20     const char* str2 = "Hello";
21     EXPECT_EQ(0, bcmp(str1, str2, strlen(str1)));
22 }
23 
24 /**
25  * @tc.name: bcmp_002
26  * @tc.desc: Verify that if two strings are not equal within the given length, the return value of bcmp function is not
27  * *         equal to the length of the first string.
28  * @tc.type: FUNC
29  */
30 HWTEST_F(StringBcmpTest, bcmp_002, TestSize.Level1)
31 {
32     const char* str1 = "hello";
33     const char* str2 = "world";
34     EXPECT_NE(bcmp(str1, str2, strlen(str1)), strlen(str1));
35 }