XmlAttributeTest.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-23
  6. * Changed: 2021-05-02
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls_std/ls_std.hpp>
  11. namespace
  12. {
  13. class XmlAttributeTest : public ::testing::Test
  14. {
  15. protected:
  16. XmlAttributeTest() = default;
  17. ~XmlAttributeTest() override = default;
  18. void SetUp() override
  19. {}
  20. void TearDown() override
  21. {}
  22. };
  23. TEST_F(XmlAttributeTest, getName)
  24. {
  25. ls_std::XmlAttribute attribute{"id"};
  26. ASSERT_STREQ("id", attribute.getName().c_str());
  27. }
  28. TEST_F(XmlAttributeTest, getValue)
  29. {
  30. ls_std::XmlAttribute attribute{"id"};
  31. ASSERT_TRUE(attribute.getValue().empty());
  32. }
  33. TEST_F(XmlAttributeTest, setName)
  34. {
  35. ls_std::XmlAttribute attribute{"id"};
  36. attribute.setName("id2");
  37. ASSERT_STREQ("id2", attribute.getName().c_str());
  38. }
  39. TEST_F(XmlAttributeTest, setValue)
  40. {
  41. ls_std::XmlAttribute attribute{"id"};
  42. attribute.setValue("some_content");
  43. ASSERT_STREQ("some_content", attribute.getValue().c_str());
  44. }
  45. TEST_F(XmlAttributeTest, toXml)
  46. {
  47. ls_std::XmlAttribute attribute{"id"};
  48. attribute.setValue("some_content");
  49. ASSERT_STREQ(R"(id="some_content")", attribute.toXml().c_str());
  50. }
  51. }