From c77a27e50a1bf875fe7c827876669d7f74840599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Wed, 9 Jun 2010 21:31:49 +0200 Subject: Remove compilation warnings from tests. 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(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(CHILDREN.size())); + CPPUNIT_ASSERT_EQUAL(1, static_cast(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(CHILDREN.size())); + CPPUNIT_ASSERT_EQUAL(1, static_cast(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(CHILDREN.size())); + CPPUNIT_ASSERT_EQUAL(1, static_cast(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(CHILDREN.size())); + CPPUNIT_ASSERT_EQUAL(1, static_cast(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(CHILDREN.size())); + CPPUNIT_ASSERT_EQUAL(1, static_cast(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(new MyPayload3())); m.addPayload(payload2); - CPPUNIT_ASSERT_EQUAL((size_t)2, m.getPayloads().size()); + CPPUNIT_ASSERT_EQUAL(static_cast(2), m.getPayloads().size()); CPPUNIT_ASSERT_EQUAL(payload1, m.getPayloads()[0]); CPPUNIT_ASSERT_EQUAL(payload2, m.getPayloads()[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(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(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(String("Ernie"), static_cast(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(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(static_cast(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(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(static_cast(roster_->getRoot()->getChildren()[0])->getChildren().size())); + CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast(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(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(static_cast(roster_->getRoot()->getChildren()[0])->getChildren().size())); + CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast(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 children = ((GroupRosterItem*)roster_->getRoot()->getDisplayedChildren()[0])->getDisplayedChildren(); - CPPUNIT_ASSERT_EQUAL(3, (int)children.size()); + std::vector children = static_cast(roster_->getRoot()->getDisplayedChildren()[0])->getDisplayedChildren(); + CPPUNIT_ASSERT_EQUAL(3, static_cast(children.size())); /* Check order */ CPPUNIT_ASSERT_EQUAL(String("Ernie"), children[0]->getDisplayName()); -- cgit v0.10.2-6-g49f6