diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2017-06-24 18:12:41 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-07-11 08:10:47 (GMT) |
commit | 8b3082e5fa56540714f3ce9b72f87965a62b5d14 (patch) | |
tree | 90ab1f432b97b2103de3708b0b6831425ccc2219 /Swiften/Serializer/PayloadSerializers/UnitTest | |
parent | f68d574ff04162e98e16a636c66ab6de5960e875 (diff) | |
download | swift-8b3082e5fa56540714f3ce9b72f87965a62b5d14.zip swift-8b3082e5fa56540714f3ce9b72f87965a62b5d14.tar.bz2 |
Add MIXPayload, its Parser and Serializer
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Added tests for MIXPayload Parser and Serializer based on examples in XEP 0369, which passes.
Tested on Ubuntu 16.04 LTS.
Change-Id: I45da05d6fe57b4be7ed8534dd84cbf0fd31ced1a
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp new file mode 100644 index 0000000..266b066 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017 Tarun Gupta + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <gtest/gtest.h> + +#include <Swiften/Serializer/PayloadSerializers/MIXPayloadSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> + +using namespace Swift; + +TEST(MIXPayloadSerializerTest, testSerializeEmpty) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\"/>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} + +TEST(MIXPayloadSerializerTest, testSerializeNick) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + mix->setNick("thirdwitch"); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">" + "<nick>thirdwitch</nick>" + "</mix>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} + +TEST(MIXPayloadSerializerTest, testSerializeJID) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + mix->setJID(JID("hecate@mix.shakespeare.example")); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">" + "<jid>hecate@mix.shakespeare.example</jid>" + "</mix>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} + +TEST(MIXPayloadSerializerTest, testSerializeAll) { + MIXPayloadSerializer testling; + + auto mix = std::shared_ptr<MIXPayload>(new MIXPayload()); + mix->setNick("thirdwitch"); + mix->setJID(JID("hecate@mix.shakespeare.example")); + mix->setSubmissionID("92vax143g"); + + std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">" + "<nick>thirdwitch</nick>" + "<jid>hecate@mix.shakespeare.example</jid>" + "<submission-id>92vax143g</submission-id>" + "</mix>"; + ASSERT_EQ(expectedResult, testling.serialize(mix)); +} |