diff options
| author | Tobias Markmann <tm@ayena.de> | 2016-10-05 14:29:42 (GMT) | 
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2016-10-05 15:07:17 (GMT) | 
| commit | 51a21158cef39a384c5869c0a0d0b476977bc7a7 (patch) | |
| tree | c2606ae173865af50c6f330a74911071fc1e28a8 | |
| parent | d29c0ee50a606bf1f4510ea427aef257870c17c0 (diff) | |
| download | swift-51a21158cef39a384c5869c0a0d0b476977bc7a7.zip swift-51a21158cef39a384c5869c0a0d0b476977bc7a7.tar.bz2 | |
Add missing sensible asserts to testing and QtMainWindow
Test-Information:
Unit tests pass in ASAN-enabled build on macOS 10.12.
Change-Id: I7a8dae7d06e5e1d3dc9391f9c9a342df384d90fc
| -rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 10 | ||||
| -rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp | 3 | 
2 files changed, 9 insertions, 4 deletions
| diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 611fc80..0c1dd97 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -6,9 +6,10 @@  #include <Swift/QtUI/QtMainWindow.h> +#include <memory> +  #include <boost/bind.hpp>  #include <boost/optional.hpp> -#include <memory>  #include <QAction>  #include <QBoxLayout> @@ -357,7 +358,7 @@ void QtMainWindow::setMyStatusType(StatusShow::Type type) {      const bool online = (type != StatusShow::None);      treeWidget_->setOnline(online);      chatListWindow_->setOnline(online); -    foreach (QAction *action, onlineOnlyActions_) { +    for (auto action : onlineOnlyActions_) {          action->setEnabled(online);      }      serverAdHocMenu_->setEnabled(online); @@ -392,18 +393,19 @@ void QtMainWindow::openCertificateDialog(const std::vector<Certificate::ref>& ch  void QtMainWindow::handleAdHocActionTriggered(bool /*checked*/) {      QAction* action = qobject_cast<QAction*>(sender());      assert(action); +    assert(serverAdHocCommandActions_.indexOf(action) >= 0);      DiscoItems::Item command = serverAdHocCommands_[serverAdHocCommandActions_.indexOf(action)];      uiEventStream_->send(std::make_shared<RequestAdHocUIEvent>(command));  }  void QtMainWindow::setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& commands) {      serverAdHocCommands_ = commands; -    foreach (QAction* action, serverAdHocCommandActions_) { +    for (auto action : serverAdHocCommandActions_) {          delete action;      }      serverAdHocMenu_->clear();      serverAdHocCommandActions_.clear(); -    foreach (DiscoItems::Item command, commands) { +    for (const auto& command : commands) {          QAction* action = new QAction(P2QSTRING(command.getName()), this);          connect(action, SIGNAL(triggered(bool)), this, SLOT(handleAdHocActionTriggered(bool)));          serverAdHocMenu_->addAction(action); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp index ace6bcb..610c4f3 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp @@ -33,6 +33,7 @@ class FormParserTest : public CppUnit::TestFixture {                  ));              Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); +            CPPUNIT_ASSERT(payload);              CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getTitle());              CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), payload->getInstructions());              CPPUNIT_ASSERT_EQUAL(Form::SubmitType, payload->getType()); @@ -65,6 +66,7 @@ class FormParserTest : public CppUnit::TestFixture {                  "</x>"));              Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); +            CPPUNIT_ASSERT(payload);              CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(payload->getFields().size()));              // PAGE ONE - parsing of element types              CPPUNIT_ASSERT_EQUAL(std::string("P1"), payload->getPages()[0]->getLabel()); @@ -126,6 +128,7 @@ class FormParserTest : public CppUnit::TestFixture {                      "</x>"));              Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); +            CPPUNIT_ASSERT(payload);              CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size()));              CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), payload->getFields()[0]->getValues()[0]); | 
 Swift
 Swift