Skip to content

Commit

Permalink
refs #6543 One more unit test and make most protected for testing
Browse files Browse the repository at this point in the history
methods back private
  • Loading branch information
abuts committed Feb 15, 2013
1 parent a0515ce commit 15d0473
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Expand Up @@ -103,16 +103,17 @@ class DLLExport LoadDetectorInfo : public API::Algorithm
/// Store a pointer to a single parameterized instrument instance
Geometry::Instrument_const_sptr m_instrument;

/// If set to true then update the detector positions base on the information in the given file
bool m_moveDets;
// Implement abstract Algorithm methods
void init();
void exec();
protected: // for testing
void readDAT(const std::string& fName);
void readRAW(const std::string& fName);
void readNXS(const std::string& fName);
/// If set to true then update the detector positions base on the information in the given file
bool m_moveDets;
private:
void readDAT(const std::string& fName);
void readRAW(const std::string& fName);

void readLibisisNXS(::NeXus::File *hFile, std::vector<detectorInfo> &detStruct,std::vector<int32_t>&detType,std::vector<float> &detOffset,std::vector<detid_t> &detList);
void readDetDotDatNXS(::NeXus::File *hFile, std::vector<detectorInfo> &detStruct,std::vector<int32_t>&detType,std::vector<float> &detOffset,std::vector<detid_t> &detList);

Expand Down
17 changes: 11 additions & 6 deletions Code/Mantid/Framework/DataHandling/test/LoadDetectorInfoTest.h
Expand Up @@ -13,6 +13,7 @@
#include "MantidGeometry/Instrument/DetectorGroup.h"
#include "MantidGeometry/Instrument/ObjComponent.h"
#include "MantidAPI/SpectraDetectorMap.h"
#include "MantidAPI/FileFinder.h"
#include <Poco/Path.h>
#include <Poco/File.h>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -50,9 +51,8 @@ namespace SmallTestDatFile
class LoadDetectorIndoTestHelper : public LoadDetectorInfo
{
public:
void readNXS(const std::string &fName,bool moveDetectors = true)
void readNXS(const std::string &fName)
{
this->m_moveDets = moveDetectors;
LoadDetectorInfo::readNXS(fName);
}
};
Expand Down Expand Up @@ -262,7 +262,8 @@ class LoadDetectorInfoTest : public CxxTest::TestSuite
{
// create a .dat file in the current directory that we'll load later
writeSmallDatFile(m_DatFile);
writeDetNXSfile(m_NXSFile,6);
// create correspondent nxs file
writeDetNXSfile(m_NXSFile,SmallTestDatFile::NDETECTS);
m_rawFile = RAWFILE;
}

Expand All @@ -279,9 +280,13 @@ class LoadDetectorInfoTest : public CxxTest::TestSuite

void testLoadNXSmisc()
{
//LoadDetectorIndoTestHelper loader;
//TS_ASSERT_THROWS(loader.readNXS("NonExistingFile"),std::invalid_argument);
//TS_ASSERT_THROWS_NOTHING(loader.readNXS("det_nxs_libisis.nxs"));
LoadDetectorIndoTestHelper loader;

TS_ASSERT_THROWS(loader.readNXS("NonExistingFile"),std::invalid_argument);

std::string nexusWithoutDet = FileFinder::Instance().getFullPath("argus0026287.nxs");
if(nexusWithoutDet.empty())return;
TSM_ASSERT_THROWS("this nexus does not have detector information ",loader.readNXS(nexusWithoutDet),std::invalid_argument);

}

Expand Down

0 comments on commit 15d0473

Please sign in to comment.