diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp | 10 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp | 19 |
2 files changed, 20 insertions, 9 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp index f155f22..dcce4dc 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp @@ -22,11 +22,11 @@ String SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel displayMarking->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(label->getDisplayMarking()))); element.addNode(displayMarking); } - if (!label->getLabel().isEmpty()) { - boost::shared_ptr<XMLElement> labelElement(new XMLElement("label")); - labelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(label->getLabel()))); - element.addNode(labelElement); - } + + boost::shared_ptr<XMLElement> labelElement(new XMLElement("label")); + labelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(label->getLabel()))); + element.addNode(labelElement); + foreach(const String& equivalentLabel, label->getEquivalentLabels()) { boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel")); equivalentLabelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(equivalentLabel))); diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp index c95ae10..e75695f 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp @@ -5,15 +5,13 @@ using namespace Swift; -class SecurityLabelSerializerTest : public CppUnit::TestFixture -{ +class SecurityLabelSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(SecurityLabelSerializerTest); CPPUNIT_TEST(testSerialize); + CPPUNIT_TEST(testSerialize_EmptyLabel); CPPUNIT_TEST_SUITE_END(); public: - SecurityLabelSerializerTest() {} - void testSerialize() { SecurityLabelSerializer testling; boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel()); @@ -38,6 +36,19 @@ class SecurityLabelSerializerTest : public CppUnit::TestFixture "</equivalentlabel>" "</securitylabel>"), testling.serialize(securityLabel)); } + + void testSerialize_EmptyLabel() { + SecurityLabelSerializer testling; + boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel()); + securityLabel->setDisplayMarking("SECRET"); + securityLabel->setLabel(""); + + CPPUNIT_ASSERT_EQUAL(String( + "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">" + "<displaymarking>SECRET</displaymarking>" + "<label></label>" + "</securitylabel>"), testling.serialize(securityLabel)); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelSerializerTest); |