summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-06-09 19:31:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-06-09 19:31:49 (GMT)
commitc77a27e50a1bf875fe7c827876669d7f74840599 (patch)
tree71fd71af487bf38a7bb7c062d3f175cbbda67d47
parent644051bad4ce7b088ea8af07c9b82a5920c96f4b (diff)
downloadswift-contrib-c77a27e50a1bf875fe7c827876669d7f74840599.zip
swift-contrib-c77a27e50a1bf875fe7c827876669d7f74840599.tar.bz2
Remove compilation warnings from tests.
-rw-r--r--3rdParty/CppUnit/SConscript9
-rw-r--r--3rdParty/hippomocks.h3
-rw-r--r--Swift/Controllers/UnitTest/RosterControllerTest.cpp22
-rw-r--r--Swiften/Elements/UnitTest/StanzaTest.cpp2
-rw-r--r--Swiften/Roster/UnitTest/RosterTest.cpp28
5 files changed, 37 insertions, 27 deletions
diff --git a/3rdParty/CppUnit/SConscript b/3rdParty/CppUnit/SConscript
index bdcea88..296f68b 100644
--- a/3rdParty/CppUnit/SConscript
+++ b/3rdParty/CppUnit/SConscript
@@ -2,13 +2,19 @@ Import("env")
if env["TEST"] :
+ if env["PLATFORM"] == "win32" :
+ cppflags = ["/I" + Dir("src/include").abspath]
+ else :
+ cppflags = [("-isystem", Dir("src/include").abspath)]
+
################################################################################
# Module flags
################################################################################
if env["SCONS_STAGE"] == "flags" :
env["CPPUNIT_FLAGS"] = {
- "CPPPATH": [env.Dir("src/include"), env.Dir(".")],
+ "CPPPATH": [env.Dir(".")],
+ "CPPFLAGS": cppflags,
"LIBPATH": [env.Dir(".")],
"LIBS": ["CppUnit"]
}
@@ -19,6 +25,7 @@ if env["TEST"] :
if env["SCONS_STAGE"] == "build" :
myenv = env.Clone()
+ myenv.Replace(CXXFLAGS = [flag for flag in env["CXXFLAGS"] if not flag.startswith("-W")])
myenv.Append(CPPPATH = ["src/include", "."])
sources = [
"src/src/cppunit/TextTestRunner.cpp",
diff --git a/3rdParty/hippomocks.h b/3rdParty/hippomocks.h
index 5a0efe3..ae819d2 100644
--- a/3rdParty/hippomocks.h
+++ b/3rdParty/hippomocks.h
@@ -1,6 +1,9 @@
#ifndef HIPPOMOCKS_H
#define HIPPOMOCKS_H
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+
#ifndef EXCEPTION_BUFFER_SIZE
#define EXCEPTION_BUFFER_SIZE 65536
#endif
diff --git a/Swift/Controllers/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
index 4bb3a08..c8eb1dc 100644
--- a/Swift/Controllers/UnitTest/RosterControllerTest.cpp
+++ b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
@@ -78,7 +78,7 @@ class RosterControllerTest : public CppUnit::TestFixture
groups.push_back("testGroup2");
xmppRoster_->addContact(JID("test@testdomain.com/bob"), "name", groups, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(2, (int)CHILDREN.size());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(CHILDREN.size()));
//CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com")));
};
@@ -87,15 +87,15 @@ class RosterControllerTest : public CppUnit::TestFixture
JID jid("test@testdomain.com");
xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::None);
- CPPUNIT_ASSERT_EQUAL(1, (int)CHILDREN.size());
- CPPUNIT_ASSERT_EQUAL(1, (int)groupChild(0)->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size()));
xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::To);
- CPPUNIT_ASSERT_EQUAL(1, (int)CHILDREN.size());
- CPPUNIT_ASSERT_EQUAL(1, (int)groupChild(0)->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size()));
xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(1, (int)CHILDREN.size());
- CPPUNIT_ASSERT_EQUAL(1, (int)groupChild(0)->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size()));
};
@@ -104,12 +104,12 @@ class RosterControllerTest : public CppUnit::TestFixture
JID jid("test@testdomain.com");
xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(1, (int)CHILDREN.size());
- CPPUNIT_ASSERT_EQUAL(1, (int)groupChild(0)->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size()));
CPPUNIT_ASSERT_EQUAL(String("name"), groupChild(0)->getChildren()[0]->getDisplayName());
xmppRoster_->addContact(jid, "NewName", groups, RosterItemPayload::Both);
- CPPUNIT_ASSERT_EQUAL(1, (int)CHILDREN.size());
- CPPUNIT_ASSERT_EQUAL(1, (int)groupChild(0)->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size()));
CPPUNIT_ASSERT_EQUAL(String("NewName"), groupChild(0)->getChildren()[0]->getDisplayName());
};
diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp
index 15f8629..27b0f09 100644
--- a/Swiften/Elements/UnitTest/StanzaTest.cpp
+++ b/Swiften/Elements/UnitTest/StanzaTest.cpp
@@ -127,7 +127,7 @@ class StanzaTest : public CppUnit::TestFixture
m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
m.addPayload(payload2);
- CPPUNIT_ASSERT_EQUAL((size_t)2, m.getPayloads<MyPayload2>().size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m.getPayloads<MyPayload2>().size());
CPPUNIT_ASSERT_EQUAL(payload1, m.getPayloads<MyPayload2>()[0]);
CPPUNIT_ASSERT_EQUAL(payload2, m.getPayloads<MyPayload2>()[1]);
}
diff --git a/Swiften/Roster/UnitTest/RosterTest.cpp b/Swiften/Roster/UnitTest/RosterTest.cpp
index 13a4ab0..5dbe5e1 100644
--- a/Swiften/Roster/UnitTest/RosterTest.cpp
+++ b/Swiften/Roster/UnitTest/RosterTest.cpp
@@ -47,31 +47,31 @@ class RosterTest : public CppUnit::TestFixture
roster_->addContact(jid2_, JID(), "Ernie", "group2");
roster_->addContact(jid3_, JID(), "Cookie", "group1");
- CPPUNIT_ASSERT_EQUAL(2, (int)roster_->getRoot()->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(roster_->getRoot()->getChildren().size()));
CPPUNIT_ASSERT_EQUAL(String("group1"), roster_->getRoot()->getChildren()[0]->getDisplayName());
CPPUNIT_ASSERT_EQUAL(String("group2"), roster_->getRoot()->getChildren()[1]->getDisplayName());
- CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
- CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
- CPPUNIT_ASSERT_EQUAL(String("Ernie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(String("Ernie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName());
}
void testRemoveContact() {
roster_->addContact(jid1_, jid1_, "Bert", "group1");
- CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
roster_->removeContact(jid1_);
- CPPUNIT_ASSERT_EQUAL(0, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size()));
}
void testRemoveSecondContact() {
roster_->addContact(jid1_, jid1_, "Bert", "group1");
roster_->addContact(jid2_, jid2_, "Cookie", "group1");
- CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
roster_->removeContact(jid2_);
- CPPUNIT_ASSERT_EQUAL(1, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
- CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size()));
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
}
void testRemoveSecondContactSameBare() {
@@ -79,11 +79,11 @@ class RosterTest : public CppUnit::TestFixture
JID jid4b("a@b/d");
roster_->addContact(jid4a, JID(), "Bert", "group1");
roster_->addContact(jid4b, JID(), "Cookie", "group1");
- CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
roster_->removeContact(jid4b);
- CPPUNIT_ASSERT_EQUAL(1, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
- CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size()));
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
}
void testApplyPresenceLikeMUC() {
@@ -108,8 +108,8 @@ class RosterTest : public CppUnit::TestFixture
presence->setFrom(jid4b);
presence->setShow(StatusShow::Online);
roster_->applyOnItems(SetPresence(presence, JID::WithResource));
- std::vector<RosterItem*> children = ((GroupRosterItem*)roster_->getRoot()->getDisplayedChildren()[0])->getDisplayedChildren();
- CPPUNIT_ASSERT_EQUAL(3, (int)children.size());
+ std::vector<RosterItem*> children = static_cast<GroupRosterItem*>(roster_->getRoot()->getDisplayedChildren()[0])->getDisplayedChildren();
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(children.size()));
/* Check order */
CPPUNIT_ASSERT_EQUAL(String("Ernie"), children[0]->getDisplayName());