diff --git a/Framework/Crystal/test/FindSXPeaksHelperTest.h b/Framework/Crystal/test/FindSXPeaksHelperTest.h index 810f51b1e066a0616d5a1067ebf328f703d849d7..80c05eb7b33bfddad57b189bbe0d012a392a03db 100644 --- a/Framework/Crystal/test/FindSXPeaksHelperTest.h +++ b/Framework/Crystal/test/FindSXPeaksHelperTest.h @@ -179,8 +179,7 @@ public: // WHEN + THEN TSM_ASSERT_THROWS("Should throw a invalid argument error when background " "strategy is not AbsoluteBackgroundStrategy", - std::make_unique<AllPeaksStrategy>( - backgroundStrategy.get(), spectrumInfo); + AllPeaksStrategy(backgroundStrategy.get(), spectrumInfo); , const std::invalid_argument &); } diff --git a/Framework/DataObjects/test/EventListTest.h b/Framework/DataObjects/test/EventListTest.h index b3776d6398564d650b10c34267a6960e3231f5c4..aea720f78c2cb72330b998cc0e6a668d874530fc 100644 --- a/Framework/DataObjects/test/EventListTest.h +++ b/Framework/DataObjects/test/EventListTest.h @@ -297,14 +297,12 @@ public: this->fake_data(); TS_ASSERT_EQUALS(el.getEvents().size(), NUMEVENTS); TS_ASSERT_EQUALS(el.getNumberEvents(), NUMEVENTS); - TS_ASSERT_THROWS(el.getWeightedEvents().size(), const std::runtime_error &); - TS_ASSERT_THROWS(el.getWeightedEventsNoTime().size(), - const std::runtime_error &); + TS_ASSERT_THROWS(el.getWeightedEvents(), const std::runtime_error &); + TS_ASSERT_THROWS(el.getWeightedEventsNoTime(), const std::runtime_error &); el.switchTo(WEIGHTED); - TS_ASSERT_THROWS(el.getEvents().size(), const std::runtime_error &); - TS_ASSERT_THROWS(el.getWeightedEventsNoTime().size(), - const std::runtime_error &); + TS_ASSERT_THROWS(el.getEvents(), const std::runtime_error &); + TS_ASSERT_THROWS(el.getWeightedEventsNoTime(), const std::runtime_error &); TS_ASSERT_EQUALS(el.getWeightedEvents().size(), NUMEVENTS); TS_ASSERT_EQUALS(el.getNumberEvents(), NUMEVENTS); TS_ASSERT_EQUALS(el.getEvent(0).weight(), 1.0); @@ -316,8 +314,8 @@ public: // Start with a bit of fake data this->fake_data(); el.switchTo(WEIGHTED_NOTIME); - TS_ASSERT_THROWS(el.getEvents().size(), const std::runtime_error &); - TS_ASSERT_THROWS(el.getWeightedEvents().size(), const std::runtime_error &); + TS_ASSERT_THROWS(el.getEvents(), const std::runtime_error &); + TS_ASSERT_THROWS(el.getWeightedEvents(), const std::runtime_error &); TS_ASSERT_EQUALS(el.getWeightedEventsNoTime().size(), NUMEVENTS); TS_ASSERT_EQUALS(el.getNumberEvents(), NUMEVENTS); TS_ASSERT_EQUALS(el.getWeightedEventsNoTime()[0].weight(), 1.0); diff --git a/Framework/DataObjects/test/Histogram1DTest.h b/Framework/DataObjects/test/Histogram1DTest.h index a9f937ee2fa56f43f2b57e3c021fbf51608d6bf7..84110bab13b16814449b401adbc93ad33509d485 100644 --- a/Framework/DataObjects/test/Histogram1DTest.h +++ b/Framework/DataObjects/test/Histogram1DTest.h @@ -15,6 +15,7 @@ #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/Histogram1D.h" #include "MantidHistogramData/LinearGenerator.h" +#include "MantidKernel/WarningSuppressions.h" using namespace Mantid; using namespace API; @@ -170,16 +171,22 @@ public: } void testrangeexceptionX() { h.setPoints(x1); + MSVC_DIAG_OFF(4834) TS_ASSERT_THROWS(h.dataX().at(nel), const std::out_of_range &); + MSVC_DIAG_ON() } void testrangeexceptionY() { h.setCounts(y1); + MSVC_DIAG_OFF(4834) TS_ASSERT_THROWS(h.dataY().at(nel), const std::out_of_range &); + MSVC_DIAG_ON() } void testrangeexceptionE() { h.setCounts(y1); h.setCountStandardDeviations(e1); + MSVC_DIAG_OFF(4834) TS_ASSERT_THROWS(h.dataE().at(nel), const std::out_of_range &); + MSVC_DIAG_ON() } void test_copy_constructor() { diff --git a/Framework/Kernel/inc/MantidKernel/WarningSuppressions.h b/Framework/Kernel/inc/MantidKernel/WarningSuppressions.h index 9535e4d28a4dd423abc3ac6add288281af055fd5..1d9de27ec97d7c72883cd7de67407c7dbbf4b999 100644 --- a/Framework/Kernel/inc/MantidKernel/WarningSuppressions.h +++ b/Framework/Kernel/inc/MantidKernel/WarningSuppressions.h @@ -76,6 +76,19 @@ #define GNU_DIAG_ON(x) #endif +// Similar macros for MSVC +#if defined(_MSC_VER) +// clang-format off +#define MSVC_DIAG_OFF(id) \ + __pragma(warning(push)) \ + __pragma(warning(disable : id)) +#define MSVC_DIAG_ON() __pragma(warning(pop)) +// clang-format on +#else +#define MSVC_DIAG_OFF(x) +#define MSVC_DIAG_ON(x) +#endif + // Defining this macro separately since clang-tidy tries to add spaces around // the hyphen and we use it in a lot of test files. // clang-format off diff --git a/Framework/Kernel/test/ThreadPoolRunnableTest.h b/Framework/Kernel/test/ThreadPoolRunnableTest.h index da6d9ca1117612c05ae04fff222304fa6cfa09bf..81180b09c15d4b38e39c115db1f7d6bdeacb5f90 100644 --- a/Framework/Kernel/test/ThreadPoolRunnableTest.h +++ b/Framework/Kernel/test/ThreadPoolRunnableTest.h @@ -22,7 +22,7 @@ int ThreadPoolRunnableTest_value; class ThreadPoolRunnableTest : public CxxTest::TestSuite { public: void test_constructor() { - TS_ASSERT_THROWS(std::make_unique<ThreadPoolRunnable>(0, nullptr), + TS_ASSERT_THROWS(ThreadPoolRunnable(0, nullptr), const std::invalid_argument &); } diff --git a/qt/widgets/common/src/FitPropertyBrowser.cpp b/qt/widgets/common/src/FitPropertyBrowser.cpp index 2da773ef2168cf38f5c53c42f508d042a90556ca..7e87c559ffee5e3657c7d5be241269e2a40ee90b 100644 --- a/qt/widgets/common/src/FitPropertyBrowser.cpp +++ b/qt/widgets/common/src/FitPropertyBrowser.cpp @@ -107,10 +107,12 @@ FitPropertyBrowser::FitPropertyBrowser(QWidget *parent, QObject *mantidui) m_shouldBeNormalised(false), m_oldWorkspaceIndex(-1) { Mantid::API::FrameworkManager::Instance().loadPlugins(); - // Try to create a Gaussian. Failing will mean that CurveFitting dll is not - // loaded - boost::shared_ptr<Mantid::API::IFunction>( - Mantid::API::FunctionFactory::Instance().createFunction("Gaussian")); + // If Gaussian does not exist then the plugins did not load. + if (!Mantid::API::FunctionFactory::Instance().exists("Gaussian")) { + throw std::runtime_error( + "FitPropertyBrowser: Unable to find Gaussian function\n" + "Has the CurveFitting plugin loaded?"); + } if (m_autoBgName.toLower() == "none") { m_autoBgName = ""; } else { diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h index f55dee81c36f962ee715b93c5620bee7ad5d4114..dd481901f488d0fe2a0a759919b7048fcefa4197 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h @@ -8,16 +8,12 @@ #define MANTID_MANTIDWIDGETS_SAFEQWTPLOT_H_ #include "MantidAPI/Workspace_fwd.h" +#include "MantidKernel/WarningSuppressions.h" #include "MantidQtWidgets/Plotting/DllOption.h" #include "qwt_text.h" -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable : 4244) -#endif +MSVC_DIAG_OFF(4244) #include <QPainter> -#if defined(_MSC_VER) -#pragma warning(pop) -#endif +MSVC_DIAG_ON() #include <qwt_plot.h> namespace MantidQt {