KvPairTest.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-25
  6. * Changed: 2022-05-14
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls_std/ls_std_core.hpp>
  11. #include <ls_std/ls_std_io.hpp>
  12. namespace
  13. {
  14. class KvPairTest : public ::testing::Test
  15. {
  16. protected:
  17. KvPairTest() = default;
  18. ~KvPairTest() override = default;
  19. void SetUp() override
  20. {}
  21. void TearDown() override
  22. {}
  23. };
  24. TEST_F(KvPairTest, constructor_with_empty_key)
  25. {
  26. EXPECT_THROW({
  27. try
  28. {
  29. ls::std::io::KvPair pair = ls::std::io::KvPair("", "1989");
  30. }
  31. catch (const ls::std::core::IllegalArgumentException &_exception)
  32. {
  33. throw;
  34. }
  35. }, ls::std::core::IllegalArgumentException);
  36. }
  37. TEST_F(KvPairTest, getKey)
  38. {
  39. ls::std::io::KvPair pair{"port", "13088"};
  40. ASSERT_STREQ("port", pair.getKey().c_str());
  41. }
  42. TEST_F(KvPairTest, getValue)
  43. {
  44. ls::std::io::KvPair pair{"port", "13088"};
  45. ASSERT_STREQ("13088", pair.getValue().c_str());
  46. }
  47. TEST_F(KvPairTest, setValue)
  48. {
  49. ls::std::io::KvPair pair{"port", "13088"};
  50. ASSERT_STREQ("13088", pair.getValue().c_str());
  51. pair.setValue("8080");
  52. ASSERT_STREQ("8080", pair.getValue().c_str());
  53. }
  54. }