diff --git a/Code/Mantid/Framework/Kernel/test/BinaryFileTest.h b/Code/Mantid/Framework/Kernel/test/BinaryFileTest.h index b8f4e3719c30cfca9ebbe297e5a7632bc2faabce..8bafc6cce0125ad1d76401c0e68fd7206e2ded6e 100644 --- a/Code/Mantid/Framework/Kernel/test/BinaryFileTest.h +++ b/Code/Mantid/Framework/Kernel/test/BinaryFileTest.h @@ -7,7 +7,6 @@ #include "MantidKernel/ConfigService.h" #include <sys/stat.h> -using namespace Mantid; using namespace Mantid::Kernel; using std::runtime_error; @@ -55,10 +54,14 @@ static void MakeDummyFile(std::string filename, size_t num_bytes) //========================================================================================== class BinaryFileTest: public CxxTest::TestSuite { -public: +private: BinaryFile<DasEvent> file; std::string dummy_file; +public: + static BinaryFileTest *createSuite() { return new BinaryFileTest(); } + static void destroySuite(BinaryFileTest *suite) { delete suite; } + BinaryFileTest() { dummy_file = "dummy.bin"; diff --git a/Code/Mantid/Framework/Kernel/test/FacilitiesTest.h b/Code/Mantid/Framework/Kernel/test/FacilitiesTest.h index 71827eb8f8b56c5ef4e392539dcce24f9e13fe9f..630d8a688866afe95889b5c8ad8d5f7b0a4f94f5 100644 --- a/Code/Mantid/Framework/Kernel/test/FacilitiesTest.h +++ b/Code/Mantid/Framework/Kernel/test/FacilitiesTest.h @@ -6,28 +6,19 @@ #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/ConfigService.h" -#include "Poco/DOM/DOMParser.h" -#include "Poco/DOM/Document.h" -#include "Poco/DOM/Element.h" -#include "Poco/DOM/NodeList.h" +#include <Poco/DOM/DOMParser.h> +#include <Poco/DOM/Document.h> +#include <Poco/DOM/Element.h> +#include <Poco/DOM/NodeList.h> #include <string> #include <fstream> using namespace Mantid::Kernel; -using Poco::XML::DOMParser; -using Poco::XML::Document; -using Poco::XML::Element; class FacilitiesTest : public CxxTest::TestSuite { public: - - FacilitiesTest() - { - - } - void testFacilities() { const std::string xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" @@ -151,8 +142,8 @@ private: FacilityInfo* getFacility(const std::string& xmlStr)const { - DOMParser parser; - Document* pDoc = parser.parseString(xmlStr); + Poco::XML::DOMParser parser; + Poco::XML::Document* pDoc = parser.parseString(xmlStr); TS_ASSERT(pDoc); Poco::XML::Element* pRootElem = pDoc->documentElement(); @@ -161,7 +152,7 @@ private: TS_ASSERT(n > 0); - Element* elem = dynamic_cast<Poco::XML::Element*>(pNL_facility->item(0)); + Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*>(pNL_facility->item(0)); TS_ASSERT(elem); return new FacilityInfo(elem); diff --git a/Code/Mantid/Framework/Kernel/test/LogFilterTest.h b/Code/Mantid/Framework/Kernel/test/LogFilterTest.h index f446656051ae31e1345608d7c0512856f0a7baf3..f4a5e7f94b361dad97abc0f6cce6f9586b5b5047 100644 --- a/Code/Mantid/Framework/Kernel/test/LogFilterTest.h +++ b/Code/Mantid/Framework/Kernel/test/LogFilterTest.h @@ -13,6 +13,9 @@ class LogFilterTest : public CxxTest::TestSuite { TimeSeriesProperty<double>* p; public: + static LogFilterTest *createSuite() { return new LogFilterTest(); } + static void destroySuite(LogFilterTest *suite) { delete suite; } + LogFilterTest() :p(new TimeSeriesProperty<double>("test")) { @@ -27,7 +30,7 @@ public: { delete p; } - + void testnthValue() { TS_ASSERT_EQUALS( p->size(), 5 ); diff --git a/Code/Mantid/Framework/Kernel/test/LogParserTest.h b/Code/Mantid/Framework/Kernel/test/LogParserTest.h index 85dc89a6dcf898512a17408362cc0e200533fad3..67d39862ff263ea0a9b4cabfe9c4de4b2f3babf5 100644 --- a/Code/Mantid/Framework/Kernel/test/LogParserTest.h +++ b/Code/Mantid/Framework/Kernel/test/LogParserTest.h @@ -9,13 +9,15 @@ #include "MantidKernel/LogParser.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "Poco/File.h" +#include <Poco/File.h> using namespace Mantid::Kernel; class LogParserTest : public CxxTest::TestSuite { -public: +public: + static LogParserTest *createSuite() { return new LogParserTest(); } + static void destroySuite(LogParserTest *suite) { delete suite; } LogParserTest() :log_num_good("TST000000_good.txt"), diff --git a/Code/Mantid/Framework/Kernel/test/MaskedPropertyTest.h b/Code/Mantid/Framework/Kernel/test/MaskedPropertyTest.h index 66cbb1ccbd63022850ad8adba12e5f3bbb23f535..f97ad86e566d0260c1a683e7b01443cda5d1997b 100644 --- a/Code/Mantid/Framework/Kernel/test/MaskedPropertyTest.h +++ b/Code/Mantid/Framework/Kernel/test/MaskedPropertyTest.h @@ -10,37 +10,23 @@ using namespace Mantid::Kernel; class MaskedPropertyTest:public CxxTest::TestSuite { public: - MaskedPropertyTest() - { - m_Property1=new MaskedProperty<std::string>("property1","value"); - m_Property2= new MaskedProperty<std::string>("property2",""); - - } - void testMaskProperty() - { - TS_ASSERT(! m_Property1->name().compare("property1") ); - TS_ASSERT(! m_Property1->value().compare("value") ); - PropertyHistory prohist=m_Property1->createHistory(); - TS_ASSERT(! prohist.value().compare("*****") ); - } - - void testMaskProperty1() - { - TS_ASSERT(! m_Property2->name().compare("property2") ); - TS_ASSERT(! m_Property2->value().compare("") ); - PropertyHistory prohist=m_Property2->createHistory(); - TS_ASSERT(! prohist.value().compare("") ); - } - - ~MaskedPropertyTest() - { - delete m_Property1; - } -private: - MaskedProperty<std::string> *m_Property1; - MaskedProperty<std::string> *m_Property2; - - + void testMaskProperty() + { + MaskedProperty<std::string> m_Property1("property1","value"); + TS_ASSERT(! m_Property1.name().compare("property1") ); + TS_ASSERT(! m_Property1.value().compare("value") ); + PropertyHistory prohist=m_Property1.createHistory(); + TS_ASSERT(! prohist.value().compare("*****") ); + } + + void testMaskProperty1() + { + MaskedProperty<std::string> m_Property2("property2",""); + TS_ASSERT(! m_Property2.name().compare("property2") ); + TS_ASSERT(! m_Property2.value().compare("") ); + PropertyHistory prohist=m_Property2.createHistory(); + TS_ASSERT(! prohist.value().compare("") ); + } }; #endif diff --git a/Code/Mantid/Framework/Kernel/test/PropertyManagerTest.h b/Code/Mantid/Framework/Kernel/test/PropertyManagerTest.h index cf067ff771fcac78ce40f6c33f9d845dbede2634..f4ac7699471a85bae66491248e79eccda421f759 100644 --- a/Code/Mantid/Framework/Kernel/test/PropertyManagerTest.h +++ b/Code/Mantid/Framework/Kernel/test/PropertyManagerTest.h @@ -22,12 +22,18 @@ public: class PropertyManagerTest : public CxxTest::TestSuite { public: - PropertyManagerTest() + void setUp() { + manager = new PropertyManagerHelper; Property *p = new PropertyWithValue<int>("aProp",1); - manager.declareProperty(p); - manager.declareProperty("anotherProp",1.11); - manager.declareProperty("yetAnotherProp","itsValue"); + manager->declareProperty(p); + manager->declareProperty("anotherProp",1.11); + manager->declareProperty("yetAnotherProp","itsValue"); + } + + void tearDown() + { + delete manager; } void testConstructor() @@ -133,35 +139,35 @@ public: void testSetPropertyValue() { - manager.setPropertyValue("APROP","10"); - TS_ASSERT( ! manager.getPropertyValue("aProp").compare("10") ); - manager.setPropertyValue("aProp","1"); - TS_ASSERT_THROWS( manager.setPropertyValue("fhfjsdf","0"), Exception::NotFoundError ); + manager->setPropertyValue("APROP","10"); + TS_ASSERT( ! manager->getPropertyValue("aProp").compare("10") ); + manager->setPropertyValue("aProp","1"); + TS_ASSERT_THROWS( manager->setPropertyValue("fhfjsdf","0"), Exception::NotFoundError ); } void testSetProperty() { - TS_ASSERT_THROWS_NOTHING( manager.setProperty("AProp",5) ); - TS_ASSERT_THROWS( manager.setProperty("wefhui",5), Exception::NotFoundError ); - TS_ASSERT_THROWS( manager.setProperty("APROP",5.55), std::invalid_argument ); - TS_ASSERT_THROWS( manager.setProperty("APROP","value"), std::invalid_argument ); - TS_ASSERT_THROWS_NOTHING( manager.setProperty("AProp",1) ); + TS_ASSERT_THROWS_NOTHING( manager->setProperty("AProp",5) ); + TS_ASSERT_THROWS( manager->setProperty("wefhui",5), Exception::NotFoundError ); + TS_ASSERT_THROWS( manager->setProperty("APROP",5.55), std::invalid_argument ); + TS_ASSERT_THROWS( manager->setProperty("APROP","value"), std::invalid_argument ); + TS_ASSERT_THROWS_NOTHING( manager->setProperty("AProp",1) ); } void testExistsProperty() { Property *p = new PropertyWithValue<int>("sjfudh",0); - TS_ASSERT( ! manager.existsProperty(p->name()) ); + TS_ASSERT( ! manager->existsProperty(p->name()) ); Property *pp = new PropertyWithValue<double>("APROP",9.99); // Note that although the name of the property is the same, the type is different - yet it passes - TS_ASSERT( manager.existsProperty(pp->name()) ); + TS_ASSERT( manager->existsProperty(pp->name()) ); delete p; delete pp; } void testValidateProperties() { - TS_ASSERT( manager.validateProperties() ); + TS_ASSERT( manager->validateProperties() ); PropertyManagerHelper mgr; mgr.declareProperty("someProp","", new MandatoryValidator<std::string>); TS_ASSERT( ! mgr.validateProperties() ); @@ -169,34 +175,34 @@ public: void testGetPropertyValue() { - TS_ASSERT( ! manager.getPropertyValue("APROP").compare("1") ); - TS_ASSERT_THROWS( manager.getPropertyValue("sdfshdu"), Exception::NotFoundError ); + TS_ASSERT( ! manager->getPropertyValue("APROP").compare("1") ); + TS_ASSERT_THROWS( manager->getPropertyValue("sdfshdu"), Exception::NotFoundError ); } void testGetProperty() { - Property *p = manager.getProperty("APROP"); + Property *p = manager->getProperty("APROP"); TS_ASSERT( p ); TS_ASSERT( ! p->name().compare("aProp") ); TS_ASSERT( ! p->value().compare("1") ); TS_ASSERT( ! p->documentation().compare("") ); TS_ASSERT( typeid(int) == *p->type_info() ); - TS_ASSERT_THROWS( p = manager.getProperty("werhui"), Exception::NotFoundError ); + TS_ASSERT_THROWS( p = manager->getProperty("werhui"), Exception::NotFoundError ); int i; - TS_ASSERT_THROWS_NOTHING( i = manager.getProperty("aprop") ); + TS_ASSERT_THROWS_NOTHING( i = manager->getProperty("aprop") ); TS_ASSERT_EQUALS( i, 1 ); double dd; - TS_ASSERT_THROWS( dd= manager.getProperty("aprop"), std::runtime_error ); - std::string s = manager.getProperty("aprop"); + TS_ASSERT_THROWS( dd= manager->getProperty("aprop"), std::runtime_error ); + std::string s = manager->getProperty("aprop"); TS_ASSERT( ! s.compare("1") ); double d; - TS_ASSERT_THROWS_NOTHING( d = manager.getProperty("anotherProp") ); + TS_ASSERT_THROWS_NOTHING( d = manager->getProperty("anotherProp") ); TS_ASSERT_EQUALS( d, 1.11 ); int ii; - TS_ASSERT_THROWS( ii = manager.getProperty("anotherprop"), std::runtime_error ); - std::string ss = manager.getProperty("anotherprop"); + TS_ASSERT_THROWS( ii = manager->getProperty("anotherprop"), std::runtime_error ); + std::string ss = manager->getProperty("anotherprop"); // Note that some versions of boost::lexical_cast > 1.34 give a string such as // 9.9900000000000002 rather than 9.99. Converting back to a double however does // still give the correct 9.99. @@ -205,13 +211,13 @@ public: // This works, but CANNOT at present declare the string on a separate line and then assign // (as I did for the int & double above) - std::string sss = manager.getProperty("yetanotherprop"); + std::string sss = manager->getProperty("yetanotherprop"); TS_ASSERT( ! sss.compare("itsValue") ); } void testGetProperties() { - std::vector<Property*> props = manager.getProperties(); + std::vector<Property*> props = manager->getProperties(); TS_ASSERT( props.size() == 3 ); Property *p = props[0]; TS_ASSERT( ! p->name().compare("aProp") ); @@ -281,7 +287,7 @@ public: private: - PropertyManagerHelper manager; + PropertyManagerHelper * manager; }; diff --git a/Code/Mantid/Framework/Kernel/test/PropertyTest.h b/Code/Mantid/Framework/Kernel/test/PropertyTest.h index edb941145e2e46d74d77fce845d59a8390a7e4f3..34c0b4e5f5fe97cfd6105b44be2a6411a6dfbab2 100644 --- a/Code/Mantid/Framework/Kernel/test/PropertyTest.h +++ b/Code/Mantid/Framework/Kernel/test/PropertyTest.h @@ -22,6 +22,9 @@ public: class PropertyTest : public CxxTest::TestSuite { public: + static PropertyTest *createSuite() { return new PropertyTest(); } + static void destroySuite(PropertyTest *suite) { delete suite; } + PropertyTest() { p = new PropertyHelper; diff --git a/Code/Mantid/Framework/Kernel/test/PropertyWithValueTest.h b/Code/Mantid/Framework/Kernel/test/PropertyWithValueTest.h index f4b5fbb0bcaae14486522eb27cde595bcdcf8f64..dd9878b0ecd812ed5d7f44ebd41a2519cfc566f8 100644 --- a/Code/Mantid/Framework/Kernel/test/PropertyWithValueTest.h +++ b/Code/Mantid/Framework/Kernel/test/PropertyWithValueTest.h @@ -13,6 +13,9 @@ using namespace Mantid::Kernel; class PropertyWithValueTest : public CxxTest::TestSuite { public: + static PropertyWithValueTest *createSuite() { return new PropertyWithValueTest(); } + static void destroySuite(PropertyWithValueTest *suite) { delete suite; } + PropertyWithValueTest() { iProp = new PropertyWithValue<int>("intProp", 1); diff --git a/Code/Mantid/Framework/Kernel/test/RebinHistogramTest.h b/Code/Mantid/Framework/Kernel/test/RebinHistogramTest.h index 2f1eacfe85726fcff1ae9b5aa08e6d8b2cce33b6..6e731656cd9b28975594638f61639df2e8c228fd 100644 --- a/Code/Mantid/Framework/Kernel/test/RebinHistogramTest.h +++ b/Code/Mantid/Framework/Kernel/test/RebinHistogramTest.h @@ -5,9 +5,6 @@ #include <vector> #include "MantidKernel/VectorHelper.h" -using namespace Mantid::Kernel; - - /// @author Laurent C Chapon, ISIS Facility, Rutherford Appleton Laboratory /// 13/03/2009 @@ -15,14 +12,7 @@ using namespace Mantid::Kernel; class RebinHistogramTest : public CxxTest::TestSuite { - public: - /// Size of vectors - int size1, size2; - /// Some vectors - std::vector<double> xin,yin,ein,xout,yout,eout; - - RebinHistogramTest(){} - +public: /// Create a new X vector where the steps are half the size of the old one. /// Perform rebin and check the values /// Y data should now contains half the intensity @@ -30,36 +20,37 @@ class RebinHistogramTest : public CxxTest::TestSuite /// Perform another rebin in the opposite direction and check that the data are identical to initial values void TestRebinSmallerSteps() { - size1=12;size2=23; - xin.resize(size1); - yin.resize(size1-1); - ein.resize(size1-1); - xout.resize(size2); - yout.resize(size2-1); - eout.resize(size2-1); - for (std::size_t i=0;i<size1-1;i++) - { - xin[i]=(double)(i); - yin[i]=1.0; - ein[i]=1.0; - } - xin[size1-1]=size1-1; - for (std::size_t i=0;i<size2;i++) - xout[i]=0.5*i; - VectorHelper::rebinHistogram(xin,yin,ein,xout,yout,eout,false); - for (std::size_t i=0;i<size2-1;i++) - { - TS_ASSERT_DELTA(yout[i],0.5,1e-7); - TS_ASSERT_DELTA(eout[i],1.0/sqrt(2.0),1e-7); - } - std::vector<double> returnX(xin), returnY(size1-1), returnE(size1-1); - - VectorHelper::rebinHistogram(xout,yout,eout,returnX,returnY,returnE,false); - for (std::size_t i=0;i<size1-1;i++) - { - TS_ASSERT_DELTA(returnY[i],yin[i],1e-7); - TS_ASSERT_DELTA(returnE[i],ein[i],1e-7); - } + // Size of vectors + int size1=12, size2=23; + std::vector<double> xin(size1); + std::vector<double> yin(size1-1); + std::vector<double> ein(size1-1); + std::vector<double> xout(size2); + std::vector<double> yout(size2-1); + std::vector<double> eout(size2-1); + for (std::size_t i=0;i<size1-1;i++) + { + xin[i]=(double)(i); + yin[i]=1.0; + ein[i]=1.0; + } + xin[size1-1]=size1-1; + for (std::size_t i=0;i<size2;i++) + xout[i]=0.5*i; + Mantid::Kernel::VectorHelper::rebinHistogram(xin,yin,ein,xout,yout,eout,false); + for (std::size_t i=0;i<size2-1;i++) + { + TS_ASSERT_DELTA(yout[i],0.5,1e-7); + TS_ASSERT_DELTA(eout[i],1.0/sqrt(2.0),1e-7); + } + std::vector<double> returnX(xin), returnY(size1-1), returnE(size1-1); + + Mantid::Kernel::VectorHelper::rebinHistogram(xout,yout,eout,returnX,returnY,returnE,false); + for (std::size_t i=0;i<size1-1;i++) + { + TS_ASSERT_DELTA(returnY[i],yin[i],1e-7); + TS_ASSERT_DELTA(returnE[i],ein[i],1e-7); + } } }; diff --git a/Code/Mantid/Framework/Kernel/test/TimerTest.h b/Code/Mantid/Framework/Kernel/test/TimerTest.h index fcda650f8fb2dafe687391743b6c7ef0aa2bcdfc..7790466310b18efabe7a38455dfee434cff85c76 100644 --- a/Code/Mantid/Framework/Kernel/test/TimerTest.h +++ b/Code/Mantid/Framework/Kernel/test/TimerTest.h @@ -15,18 +15,18 @@ public: // Instantiating the object starts the timer Mantid::Kernel::Timer timer; #ifdef _WIN32 - Sleep(2000); + Sleep(40); #else - sleep(2); + usleep(40000); #endif - TS_ASSERT_DELTA( timer.elapsed(), 2.00, 0.01 ); + TS_ASSERT_DELTA( timer.elapsed(), 0.04, 0.002 ); #ifdef _WIN32 - Sleep(1000); + Sleep(20); #else - sleep(1); + usleep(20000); #endif // Calling elapsed above should reset the timer - TS_ASSERT_DELTA( timer.elapsed(), 1.00, 0.01 ); + TS_ASSERT_DELTA( timer.elapsed(), 0.02, 0.002 ); } };