summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp18
2 files changed, 22 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp
index 86d8830..0f464a4 100644
--- a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp
@@ -45,6 +45,10 @@ std::string ResultSetSerializer::serializePayload(boost::shared_ptr<ResultSet> p
element.addNode(boost::make_shared<XMLElement>("last", "", *payload->getLastID()));
}
+ if (payload->getBefore()) {
+ element.addNode(boost::make_shared<XMLElement>("before", "", *payload->getBefore()));
+ }
+
if (payload->getAfter()) {
element.addNode(boost::make_shared<XMLElement>("after", "", *payload->getAfter()));
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp
index 641b856..354db85 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ResultSetSerializerTest.cpp
@@ -19,6 +19,7 @@ class ResultSetSerializerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ResultSetSerializerTest);
CPPUNIT_TEST(testSerializeFull);
CPPUNIT_TEST(testSerializeMaxItems);
+ CPPUNIT_TEST(testSerializeEmptyBefore);
CPPUNIT_TEST(testSerializeFirst);
CPPUNIT_TEST(testSerializeFirstWithIndex);
CPPUNIT_TEST_SUITE_END();
@@ -35,6 +36,7 @@ class ResultSetSerializerTest : public CppUnit::TestFixture {
resultSet->setFirstID(std::string("stpeter@jabber.org"));
resultSet->setLastID(std::string("peterpan@neverland.lit"));
resultSet->setAfter(std::string("09af3-cc343-b409f"));
+ resultSet->setBefore(std::string("decaf-badba-dbad1"));
std::string expectedResult =
"<set xmlns=\"http://jabber.org/protocol/rsm\">"
@@ -42,6 +44,7 @@ class ResultSetSerializerTest : public CppUnit::TestFixture {
"<count>800</count>"
"<first index=\"123\">stpeter@jabber.org</first>"
"<last>peterpan@neverland.lit</last>"
+ "<before>decaf-badba-dbad1</before>"
"<after>09af3-cc343-b409f</after>"
"</set>";
@@ -63,6 +66,21 @@ class ResultSetSerializerTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
}
+ void testSerializeEmptyBefore() {
+ ResultSetSerializer serializer;
+
+ boost::shared_ptr<ResultSet> resultSet(boost::make_shared<ResultSet>());
+
+ resultSet->setBefore(std::string());
+
+ std::string expectedResult =
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<before/>"
+ "</set>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(resultSet));
+ }
+
void testSerializeFirst() {
ResultSetSerializer serializer;