ProtocolFamilyMapperTest.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-16
  6. * Changed: 2022-12-09
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls_std/ls_std_network.hpp>
  11. #if defined(unix) || defined(__APPLE__)
  12. #include <sys/socket.h>
  13. #endif
  14. #include <ls_std/ls_std_core.hpp>
  15. using namespace ls::std::network;
  16. using namespace ls::std::core;
  17. namespace
  18. {
  19. class ProtocolFamilyMapperTest : public ::testing::Test
  20. {
  21. protected:
  22. ProtocolFamilyMapperTest() = default;
  23. ~ProtocolFamilyMapperTest() override = default;
  24. void SetUp() override
  25. {}
  26. void TearDown() override
  27. {}
  28. };
  29. TEST_F(ProtocolFamilyMapperTest, getClassName)
  30. {
  31. ASSERT_STREQ("ProtocolFamilyMapper", ProtocolFamilyMapper{}.getClassName().c_str());
  32. }
  33. TEST_F(ProtocolFamilyMapperTest, from)
  34. {
  35. ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4);
  36. #if defined(unix) || defined(__APPLE__)
  37. ASSERT_EQ(AF_INET, convertedProtocolFamily.unixDomain);
  38. #endif
  39. }
  40. TEST_F(ProtocolFamilyMapperTest, from_invalid_protocol_family_type)
  41. {
  42. EXPECT_THROW({
  43. try
  44. {
  45. ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED);
  46. }
  47. catch (const IllegalArgumentException &_exception)
  48. {
  49. throw;
  50. }
  51. }, IllegalArgumentException);
  52. }
  53. }