KvPairTest.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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-11
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls_std/ls_std.hpp>
  11. namespace
  12. {
  13. class KvPairTest : public ::testing::Test
  14. {
  15. protected:
  16. KvPairTest() = default;
  17. ~KvPairTest() override = default;
  18. void SetUp() override
  19. {}
  20. void TearDown() override
  21. {}
  22. };
  23. TEST_F(KvPairTest, constructor_with_empty_key)
  24. {
  25. EXPECT_THROW({
  26. try
  27. {
  28. ls::std::io::KvPair pair = ls::std::io::KvPair("", "1989");
  29. }
  30. catch (const ls::std::core::IllegalArgumentException &_exception)
  31. {
  32. throw;
  33. }
  34. }, ls::std::core::IllegalArgumentException);
  35. }
  36. TEST_F(KvPairTest, getKey)
  37. {
  38. ls::std::io::KvPair pair{"port", "13088"};
  39. ASSERT_STREQ("port", pair.getKey().c_str());
  40. }
  41. TEST_F(KvPairTest, getValue)
  42. {
  43. ls::std::io::KvPair pair{"port", "13088"};
  44. ASSERT_STREQ("13088", pair.getValue().c_str());
  45. }
  46. TEST_F(KvPairTest, setValue)
  47. {
  48. ls::std::io::KvPair pair{"port", "13088"};
  49. ASSERT_STREQ("13088", pair.getValue().c_str());
  50. pair.setValue("8080");
  51. ASSERT_STREQ("8080", pair.getValue().c_str());
  52. }
  53. }