1 #include <gtest/gtest.h> 2 #include <netdb.h> 3 using namespace testing::ext; 4 5 class NetworkHerrorTest : public testing::Test { SetUp()6 void SetUp() override {} TearDown()7 void TearDown() override {} 8 }; 9 10 /** 11 * @tc.name: herror_001 12 * @tc.desc: The herror function is called to print an error message 13 * @tc.type: FUNC 14 **/ 15 HWTEST_F(NetworkHerrorTest, herror_001, TestSize.Level1) 16 { 17 struct hostent* hostInfo; 18 hostInfo = gethostbyname("nonexistenthostname"); 19 if (hostInfo == nullptr) { 20 herror("gethostbyname failed"); 21 } 22 }