summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-23 07:09:39 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-23 11:30:02 (GMT)
commite405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch)
tree9118ef838ebfaec1df90ec24761944b5d833774c /Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
parent8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff)
downloadswift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip
swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information: Build on macOS 10.12.1 and all tests pass. Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
index 18597bd..f0cf68d 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
@@ -1,69 +1,68 @@
/*
* Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/MUCDestroyPayload.h>
#include <Swiften/Parser/PayloadParsers/MUCUserPayloadParser.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
using namespace Swift;
class MUCUserPayloadParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(MUCUserPayloadParserTest);
CPPUNIT_TEST(testParseEmpty);
CPPUNIT_TEST(testParse);
CPPUNIT_TEST(testParseDestroy);
CPPUNIT_TEST(testParseInvite);
CPPUNIT_TEST_SUITE_END();
public:
MUCUserPayloadParserTest() {}
void testParse() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><status code='110'/><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item><status code='210'/></x>"));
bool found110 = false;
bool found210 = false;
MUCUserPayload::ref payload = std::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
- foreach (MUCUserPayload::StatusCode status, payload->getStatusCodes()) {
+ for (const auto& status : payload->getStatusCodes()) {
if (status.code == 110) found110 = true;
if (status.code == 210) found210 = true;
}
MUCItem item = payload->getItems()[0];
CPPUNIT_ASSERT_EQUAL(MUCOccupant::Owner, item.affiliation.get());
CPPUNIT_ASSERT_EQUAL(MUCOccupant::Visitor, item.role.get());
CPPUNIT_ASSERT_EQUAL(JID("kev@tester.lit"), item.actor.get());
CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
CPPUNIT_ASSERT(found110);
CPPUNIT_ASSERT(found210);
}
void testParseEmpty() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"/>"));
MUCUserPayload::ref payload = std::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
CPPUNIT_ASSERT(payload);
CPPUNIT_ASSERT(payload->getItems().empty());
}
void testParseDestroy() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><destroy jid='alice@wonderland.lit'><reason>bert</reason></destroy></x>"));
MUCUserPayload::ref payload = std::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
CPPUNIT_ASSERT(payload);