ProtocolMapperTest.cpp 1.5 KB

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