Migrate ethernet_test.cpp from Gerrit to Google3. Google-Bug-Id:548089846 PiperOrigin-RevId: 970200339 Change-Id: I222b580a54dc1b7cf7b64163daa00699137bacd6
diff --git a/copy.bara.sky b/copy.bara.sky index d2a02cf..5f2a823 100644 --- a/copy.bara.sky +++ b/copy.bara.sky
@@ -275,6 +275,7 @@ ("test/redfish_core/lib/chassis_test.cc", "test/redfish-core/lib/chassis_test.cpp"), ("test/redfish_core/lib/component_integrity_test.cc", "test/redfish-core/lib/component_integrity_test.cpp"), ("test/redfish_core/lib/control_test.cc", "test/redfish-core/lib/control_test.cpp"), + ("test/redfish_core/lib/ethernet_test.cc", "test/redfish-core/lib/ethernet_test.cpp"), ("test/redfish_core/lib/external_storer_test.cc", "test/redfish-core/lib/external_storer_test.cpp"), ("test/redfish_core/lib/fan_test.cc", "test/redfish-core/lib/fan_test.cpp"), ("test/redfish_core/lib/health_test.cc", "test/redfish-core/lib/health_test.cpp"),
diff --git a/test/redfish-core/lib/ethernet_test.cpp b/test/redfish-core/lib/ethernet_test.cpp index f3899be..303ae37 100644 --- a/test/redfish-core/lib/ethernet_test.cpp +++ b/test/redfish-core/lib/ethernet_test.cpp
@@ -1,54 +1,45 @@ -#include "async_resp.hpp" #include "ethernet.hpp" -#include <boost/beast/http/status.hpp> - #include <string> #include <gtest/gtest.h> -namespace redfish -{ -namespace -{ +namespace redfish { +namespace { -TEST(EthernetHostnameValidation, ValidHostnames) -{ - EXPECT_TRUE(isHostnameValid("bmc")); - EXPECT_TRUE(isHostnameValid("host1")); - EXPECT_TRUE(isHostnameValid("a")); - EXPECT_TRUE(isHostnameValid("host-name")); - EXPECT_TRUE(isHostnameValid("1host")); - EXPECT_TRUE(isHostnameValid(std::string(63, 'a'))); +TEST(EthernetHostnameValidation, ValidHostnames) { + EXPECT_TRUE(isHostnameValid("bmc")); + EXPECT_TRUE(isHostnameValid("host1")); + EXPECT_TRUE(isHostnameValid("a")); + EXPECT_TRUE(isHostnameValid("host-name")); + EXPECT_TRUE(isHostnameValid("1host")); + EXPECT_TRUE(isHostnameValid(std::string(63, 'a'))); } -TEST(EthernetHostnameValidation, InvalidHostnames) -{ - EXPECT_FALSE(isHostnameValid("")); - EXPECT_FALSE(isHostnameValid("19216811")); - EXPECT_FALSE(isHostnameValid("-host")); - EXPECT_FALSE(isHostnameValid("host-")); - EXPECT_FALSE(isHostnameValid("host.name")); - EXPECT_FALSE(isHostnameValid(std::string(64, 'a'))); +TEST(EthernetHostnameValidation, InvalidHostnames) { + EXPECT_FALSE(isHostnameValid("")); + EXPECT_FALSE(isHostnameValid("19216811")); + EXPECT_FALSE(isHostnameValid("-host")); + EXPECT_FALSE(isHostnameValid("host-")); + EXPECT_FALSE(isHostnameValid("host.name")); + EXPECT_FALSE(isHostnameValid(std::string(64, 'a'))); } -TEST(EthernetDomainnameValidation, ValidDomainnames) -{ - EXPECT_TRUE(isDomainnameValid("example.com")); - EXPECT_TRUE(isDomainnameValid("sub.example.com")); - EXPECT_TRUE(isDomainnameValid("a.bc")); +TEST(EthernetDomainnameValidation, ValidDomainnames) { + EXPECT_TRUE(isDomainnameValid("example.com")); + EXPECT_TRUE(isDomainnameValid("sub.example.com")); + EXPECT_TRUE(isDomainnameValid("a.bc")); } -TEST(EthernetDomainnameValidation, InvalidDomainnames) -{ - EXPECT_FALSE(isDomainnameValid("")); - EXPECT_FALSE(isDomainnameValid("a")); - EXPECT_FALSE(isDomainnameValid("a.b")); - EXPECT_FALSE(isDomainnameValid("-example.com")); - EXPECT_FALSE(isDomainnameValid("example-.com")); - EXPECT_FALSE(isDomainnameValid("example.c")); - EXPECT_FALSE(isDomainnameValid("example.com.")); +TEST(EthernetDomainnameValidation, InvalidDomainnames) { + EXPECT_FALSE(isDomainnameValid("")); + EXPECT_FALSE(isDomainnameValid("a")); + EXPECT_FALSE(isDomainnameValid("a.b")); + EXPECT_FALSE(isDomainnameValid("-example.com")); + EXPECT_FALSE(isDomainnameValid("example-.com")); + EXPECT_FALSE(isDomainnameValid("example.c")); + EXPECT_FALSE(isDomainnameValid("example.com.")); } -} // namespace -} // namespace redfish +} // namespace +} // namespace redfish