From 38dd96002d4ae1f8817d236b4678edba90f67e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 21 Nov 2010 13:00:43 +0100 Subject: Added missing file. diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp new file mode 100644 index 0000000..40951ec --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include +#include + +#include "Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h" + +using namespace Swift; + +class SearchPayloadSerializerTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(SearchPayloadSerializerTest); + CPPUNIT_TEST(testSerialize_Request); + CPPUNIT_TEST(testSerialize_Items); + CPPUNIT_TEST_SUITE_END(); + + public: + void testSerialize_Request() { + SearchPayloadSerializer testling; + + SearchPayload::ref payload(new SearchPayload()); + payload->setFirst("Juliet"); + payload->setLast("Capulet"); + + CPPUNIT_ASSERT_EQUAL(String( + "" + "Juliet" + "Capulet" + "" + ), testling.serialize(payload)); + } + + void testSerialize_Items() { + SearchPayloadSerializer testling; + + SearchPayload::ref payload(new SearchPayload()); + SearchPayload::Item item1; + item1.jid = JID("juliet@capulet.com"); + item1.first = "Juliet"; + item1.last = "Capulet"; + item1.nick = "JuliC"; + item1.email = "juliet@shakespeare.lit"; + payload->addItem(item1); + + SearchPayload::Item item2; + item2.jid = JID("tybalt@shakespeare.lit"); + item2.first = "Tybalt"; + item2.last = "Capulet"; + item2.nick = "ty"; + item2.email = "tybalt@shakespeare.lit"; + payload->addItem(item2); + + CPPUNIT_ASSERT_EQUAL(String( + "" + "" + "Juliet" + "Capulet" + "JuliC" + "juliet@shakespeare.lit" + "" + "" + "Tybalt" + "Capulet" + "ty" + "tybalt@shakespeare.lit" + "" + "" + ), testling.serialize(payload)); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(SearchPayloadSerializerTest); -- cgit v0.10.2-6-g49f6