当前位置: 首页>>代码示例>>C++>>正文


C++ PayloadsParserTester类代码示例

本文整理汇总了C++中PayloadsParserTester的典型用法代码示例。如果您正苦于以下问题:C++ PayloadsParserTester类的具体用法?C++ PayloadsParserTester怎么用?C++ PayloadsParserTester使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PayloadsParserTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testParse

		void testParse() {
			PayloadsParserTester parser;
			CPPUNIT_ASSERT(parser.parse(
				"<query xmlns='jabber:iq:roster'>"
				"	<item jid='[email protected]' name='Foo @ Bar' subscription='from' ask='subscribe'>"
				"		<group>Group 1</group>"
				"		<group>Group 2</group>"
				"	</item>"
				" <item jid='[email protected]' name='Baz'/>"
				"</query>"));

			RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());

			CPPUNIT_ASSERT(!payload->getVersion());
			const RosterPayload::RosterItemPayloads& items = payload->getItems();

			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());

			CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), items[0].getJID());
			CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName());
			CPPUNIT_ASSERT_EQUAL(RosterItemPayload::From, items[0].getSubscription());
			CPPUNIT_ASSERT(items[0].getSubscriptionRequested());
			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size());
			CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
			CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);

			CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), items[1].getJID());
			CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName());
			CPPUNIT_ASSERT_EQUAL(RosterItemPayload::None, items[1].getSubscription());
			CPPUNIT_ASSERT(!items[1].getSubscriptionRequested());
			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size());
		}
开发者ID:pedrosorren,项目名称:swift,代码行数:32,代码来源:RosterParserTest.cpp

示例2: testParse_Results

        void testParse_Results() {
            PayloadsParserTester parser;

            CPPUNIT_ASSERT(parser.parse(
                    "<query xmlns=\"jabber:iq:search\">"
                        "<item jid=\"[email protected]\">"
                            "<first>Juliet</first>"
                            "<last>Capulet</last>"
                            "<nick>JuliC</nick>"
                            "<email>[email protected]</email>"
                        "</item>"
                        "<item jid=\"[email protected]\">"
                            "<first>Tybalt</first>"
                            "<last>Capulet</last>"
                            "<nick>ty</nick>"
                            "<email>[email protected]</email>"
                        "</item>"
                    "</query>"
                ));

            SearchPayload::ref payload = parser.getPayload<SearchPayload>();
            CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size()));
            CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), payload->getItems()[0].jid);
            CPPUNIT_ASSERT_EQUAL(std::string("Juliet"), payload->getItems()[0].first);
            CPPUNIT_ASSERT_EQUAL(std::string("Capulet"), payload->getItems()[0].last);
            CPPUNIT_ASSERT_EQUAL(std::string("JuliC"), payload->getItems()[0].nick);
            CPPUNIT_ASSERT_EQUAL(std::string("[email protected]"), payload->getItems()[0].email);
            CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), payload->getItems()[1].jid);
        }
开发者ID:jakjothi,项目名称:swift,代码行数:29,代码来源:SearchPayloadParserTest.cpp

示例3: testParse

        void testParse() {
            PayloadsParserTester parser;

            CPPUNIT_ASSERT(parser.parse(
                "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
                    "<displaymarking fgcolor=\"black\" bgcolor=\"red\">SECRET</displaymarking>"
                    "<label>"
                        "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"
                    "</label>"
                    "<equivalentlabel>"
                        "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"
                    "</equivalentlabel>"
                    "<equivalentlabel>"
                        "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"
                    "</equivalentlabel>"
                "</securitylabel>"));

            SecurityLabel* payload = dynamic_cast<SecurityLabel*>(parser.getPayload().get());
            CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getDisplayMarking());
            CPPUNIT_ASSERT_EQUAL(std::string("black"), payload->getForegroundColor());
            CPPUNIT_ASSERT_EQUAL(std::string("red"), payload->getBackgroundColor());
            CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabel());
            CPPUNIT_ASSERT_EQUAL(std::string("<icismlabel classification=\"S\" disseminationControls=\"FOUO\" ownerProducer=\"USA\" xmlns=\"http://example.gov/IC-ISM/0\"/>"), payload->getEquivalentLabels()[0]);
            CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"), payload->getEquivalentLabels()[1]);
        }
开发者ID:jakjothi,项目名称:swift,代码行数:25,代码来源:SecurityLabelParserTest.cpp

示例4: testParseExample12

		/*
		 * Test parsing of example 12 in XEP-0280.
		 */
		void testParseExample12() {
			PayloadsParserTester parser;
			CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:carbons:2'>"
											"<forwarded xmlns='urn:xmpp:forward:0'>"
												"<message xmlns='jabber:client'"
													" from='[email protected]/balcony'"
													" to='[email protected]/garden'"
													" type='chat'>"
													"<body>What man art thou that, thus bescreen'd in night, so stumblest on my counsel?</body>"
													"<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
												"</message>"
											"</forwarded>"
										"</received>"));

			CarbonsReceived::ref received = parser.getPayload<CarbonsReceived>();
			CPPUNIT_ASSERT(received);

			boost::shared_ptr<Forwarded> forwarded = received->getForwarded();
			CPPUNIT_ASSERT(forwarded);

			boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
			CPPUNIT_ASSERT(message);
			CPPUNIT_ASSERT_EQUAL(JID("[email protected]/balcony"), message->getFrom());

			boost::shared_ptr<Thread> thread = message->getPayload<Thread>();
			CPPUNIT_ASSERT(thread);
			CPPUNIT_ASSERT_EQUAL(std::string("0e3141cd80894871a68e6fe6b1ec56fa"), thread->getText());
		}
开发者ID:pedrosorren,项目名称:swift,代码行数:31,代码来源:CarbonsParserTest.cpp

示例5: testParseExample6

		/*
		 * Test parsing of example 6 in XEP-0280.
		 */
		void testParseExample6() {
			PayloadsParserTester parser;
			CPPUNIT_ASSERT(parser.parse("<disable xmlns='urn:xmpp:carbons:2' />"));

			CarbonsDisable::ref disable = parser.getPayload<CarbonsDisable>();
			CPPUNIT_ASSERT(disable);
		}
开发者ID:pedrosorren,项目名称:swift,代码行数:10,代码来源:CarbonsParserTest.cpp

示例6: testParse

        void testParse() {
            PayloadsParserTester parser;
            CPPUNIT_ASSERT(parser.parse(
                "<set xmlns=\"http://jabber.org/protocol/rsm\">"
                    "<max>100</max>"
                    "<count>800</count>"
                    "<index>0</index>"
                    "<first index=\"123\">[email protected]</first>"
                    "<last>[email protected]</last>"
                    "<before>decaf-badba-dbad1</before>"
                    "<after>09af3-cc343-b409f</after>"
                "</set>"));

            std::shared_ptr<ResultSet> payload = parser.getPayload<ResultSet>();
            CPPUNIT_ASSERT(!!payload);
            CPPUNIT_ASSERT(payload->getMaxItems());
            CPPUNIT_ASSERT_EQUAL(100, *payload->getMaxItems());
            CPPUNIT_ASSERT(payload->getCount());
            CPPUNIT_ASSERT_EQUAL(800, *payload->getCount());
            CPPUNIT_ASSERT(payload->getIndex());
            CPPUNIT_ASSERT_EQUAL(0, *payload->getIndex());
            CPPUNIT_ASSERT(payload->getFirstID());
            CPPUNIT_ASSERT_EQUAL(std::string("[email protected]"), *payload->getFirstID());
            CPPUNIT_ASSERT(payload->getFirstIDIndex());
            CPPUNIT_ASSERT_EQUAL(123, *payload->getFirstIDIndex());
            CPPUNIT_ASSERT(payload->getLastID());
            CPPUNIT_ASSERT_EQUAL(std::string("[email protected]"), *payload->getLastID());
            CPPUNIT_ASSERT(payload->getBefore());
            CPPUNIT_ASSERT_EQUAL(std::string("decaf-badba-dbad1"), *payload->getBefore());
            CPPUNIT_ASSERT(payload->getAfter());
            CPPUNIT_ASSERT_EQUAL(std::string("09af3-cc343-b409f"), *payload->getAfter());
        }
开发者ID:jakjothi,项目名称:swift,代码行数:32,代码来源:ResultSetParserTest.cpp

示例7: testParse_Result

		void testParse_Result() {
			PayloadsParserTester parser;

			CPPUNIT_ASSERT(parser.parse(
				"<command xmlns='http://jabber.org/protocol/commands' node='config' status='completed' sessionid='myid'>"
					"<note type='warn'>Service 'httpd' has been configured.</note>"
					"<note type='error'>I lied.</note>"
					"<actions execute='next'>"
						"<prev/>"
						"<next/>"
					"</actions>"
				"</command>"
				));

			Command::ref payload = parser.getPayload<Command>();
			CPPUNIT_ASSERT_EQUAL(Command::Completed, payload->getStatus());
			std::vector<Command::Note> notes = payload->getNotes();
			CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(notes.size()));
			CPPUNIT_ASSERT_EQUAL(Command::Note::Warn, notes[0].type);
			CPPUNIT_ASSERT_EQUAL(std::string("Service 'httpd' has been configured."), notes[0].note);
			CPPUNIT_ASSERT_EQUAL(Command::Note::Error, notes[1].type);
			CPPUNIT_ASSERT_EQUAL(std::string("I lied."), notes[1].note);
			std::vector<Command::Action> actions = payload->getAvailableActions();
			CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(actions.size()));
			CPPUNIT_ASSERT_EQUAL(Command::Prev, actions[0]);
			CPPUNIT_ASSERT_EQUAL(Command::Next, actions[1]);
			CPPUNIT_ASSERT_EQUAL(Command::Next, payload->getExecuteAction());
		}
开发者ID:marosi,项目名称:SocialDesktopClient,代码行数:28,代码来源:CommandParserTest.cpp

示例8: testParse_Node

        void testParse_Node() {
            PayloadsParserTester parser;

            CPPUNIT_ASSERT(parser.parse(
                "<query xmlns=\"http://jabber.org/protocol/disco#info\" node=\"blahblah\">"
                    "<identity name=\"Swift\" category=\"client\" type=\"pc\" xml:lang=\"en\"/>"
                    "<identity name=\"Vlug\" category=\"client\" type=\"pc\" xml:lang=\"nl\"/>"
                    "<feature var=\"foo-feature\"/>"
                    "<feature var=\"bar-feature\"/>"
                    "<feature var=\"baz-feature\"/>"
                "</query>"));

            DiscoInfo::ref payload = std::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
            CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
            CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName());
            CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType());
            CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory());
            CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage());
            CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName());
            CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType());
            CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory());
            CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage());
            CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
            CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
            CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
            CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
            CPPUNIT_ASSERT_EQUAL(std::string("blahblah"), payload->getNode());
        }
开发者ID:jakjothi,项目名称:swift,代码行数:28,代码来源:DiscoInfoParserTest.cpp

示例9: testParse_Request

		void testParse_Request() {
			PayloadsParserTester parser;

			CPPUNIT_ASSERT(parser.parse(
					"<si xmlns='http://jabber.org/protocol/si' id='a0' mime-type='text/plain' profile='http://jabber.org/protocol/si/profile/file-transfer'>"
						"<file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='test.txt' size='1022'>"
					    "<desc>This is info about the file.</desc>"
						"</file>"
						"<feature xmlns='http://jabber.org/protocol/feature-neg'>"
							"<x xmlns='jabber:x:data' type='form'>"
								"<field var='stream-method' type='list-single'>"
									"<option><value>http://jabber.org/protocol/bytestreams</value></option>"
									"<option><value>jabber:iq:oob</value></option>"
									"<option><value>http://jabber.org/protocol/ibb</value></option>"
								"</field>"
							"</x>"
						"</feature>"
					"</si>"
			));

			StreamInitiation::ref si = parser.getPayload<StreamInitiation>();
			CPPUNIT_ASSERT(si->getIsFileTransfer());
			CPPUNIT_ASSERT(si->getFileInfo());
			CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), si->getFileInfo()->getName());
			CPPUNIT_ASSERT(1022 == si->getFileInfo()->getSize());
			CPPUNIT_ASSERT_EQUAL(std::string("This is info about the file."), si->getFileInfo()->getDescription());
			CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(si->getProvidedMethods().size()));
			CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getProvidedMethods()[0]);
			CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:oob"), si->getProvidedMethods()[1]);
			CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/ibb"), si->getProvidedMethods()[2]);
		}
开发者ID:pedrosorren,项目名称:swift,代码行数:31,代码来源:StreamInitiationParserTest.cpp

示例10: testParse_WithEmptyVersion

		void testParse_WithEmptyVersion() {
			PayloadsParserTester parser;
			CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:roster' ver=''/>"));

			RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
			CPPUNIT_ASSERT(payload->getVersion());
			CPPUNIT_ASSERT_EQUAL(std::string(""), *payload->getVersion());
		}
开发者ID:pedrosorren,项目名称:swift,代码行数:8,代码来源:RosterParserTest.cpp

示例11: testParseXEP0184Example4

        void testParseXEP0184Example4() {
            PayloadsParserTester parser;
            CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/>"));

            DeliveryReceipt::ref receipt = std::dynamic_pointer_cast<DeliveryReceipt>(parser.getPayload());

            CPPUNIT_ASSERT_EQUAL(std::string("richard2-4.1.247"), receipt->getReceivedID());
        }
开发者ID:jakjothi,项目名称:swift,代码行数:8,代码来源:DeliveryReceiptParserTest.cpp

示例12: testParseXEP0184Example3

        void testParseXEP0184Example3() {
            PayloadsParserTester parser;
            CPPUNIT_ASSERT(parser.parse("<request xmlns='urn:xmpp:receipts'/>"));

            DeliveryReceiptRequest::ref request = std::dynamic_pointer_cast<DeliveryReceiptRequest>(parser.getPayload());

            CPPUNIT_ASSERT(request);
        }
开发者ID:jakjothi,项目名称:swift,代码行数:8,代码来源:DeliveryReceiptParserTest.cpp

示例13: testParse_Resource

		void testParse_Resource() {
			PayloadsParserTester parser;

			CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>someresource</resource></bind>"));

			ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
			CPPUNIT_ASSERT_EQUAL(std::string("someresource"), payload->getResource());
		}
开发者ID:marosi,项目名称:SocialDesktopClient,代码行数:8,代码来源:ResourceBindParserTest.cpp

示例14: testParse_JID

		void testParse_JID() {
			PayloadsParserTester parser;

			CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>[email protected]/someresource</jid></bind>"));

			ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
			CPPUNIT_ASSERT_EQUAL(JID("[email protected]/someresource"), payload->getJID());
		}
开发者ID:marosi,项目名称:SocialDesktopClient,代码行数:8,代码来源:ResourceBindParserTest.cpp

示例15: testParse_DND

		void testParse_DND() {
			PayloadsParserTester parser;
			
			CPPUNIT_ASSERT(parser.parse("<show>dnd</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::DND == payload->getType());
		}
开发者ID:pedrosorren,项目名称:swift,代码行数:8,代码来源:StatusShowParserTest.cpp


注:本文中的PayloadsParserTester类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。